-
-
Couldn't load subscription status.
- Fork 19.2k
MNT: migrate from codecs.open to open #62073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| assert not icom.is_fsspec_url("filecache::://pandas/test.csv") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("encoding", [None, "utf-8"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could also keep testing this but CPython warns about using open(..., encoding=None): EncodingWarning: 'encoding' argument not specified. In this case we are explicitly specifying None but I don't think CPython can tell the difference.
| else: | ||
| assert isinstance(as_json, str) # needed for mypy | ||
| with codecs.open(as_json, "wb", encoding="utf8") as f: | ||
| with open(as_json, "w", encoding="utf-8") as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it from "wb" to "w" because I think the "b" here is a bug (bytes and utf-8???)
|
Thanks @ngoldbaum |
c.f. #61950, towards supporting Python 3.14
See the 3.14 deprecations and python/cpython#133036 for more details.
There is one spot that was nontrivial - the use in
pandas.util._print_versionsI think was buggy - it wanted to write a file in bytes mode and also specified an encoding.codecs.opendidn't blink at this but regularopenis more restrictive. I think what I updated it to is correct and this is a latent bug, probably introduced a long time ago in the 2->3 transition.doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.