-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Misc PY2/3 compat functions #26008
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
get_option('display.encoding')) | ||
) | ||
text = text.decode(kwargs.get('encoding') or | ||
get_option('display.encoding')) | ||
except AttributeError: |
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.
Maybe take the getoption outside of the try/except?
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.
Hmm...that encoding
logic is specific to the try-except
block. I'm not sure we should be putting it outside.
In addition, since this is supposed to be pure removal, I'm uneasy about making other changes beyond the stated purpose of removing PY2 / 3 things.
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.
Fine by me. Moved back in the try except.
pandas/tests/io/json/test_ujson.py
Outdated
@@ -654,7 +654,7 @@ def test_decode_big_escape(self): | |||
# Make sure no Exception is raised. | |||
for _ in range(10): | |||
base = '\u00e5'.encode("utf-8") | |||
quote = compat.str_to_bytes("\"") | |||
quote = "\"".encode('ascii') |
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.
b’”’
Codecov Report
@@ Coverage Diff @@
## master #26008 +/- ##
==========================================
+ Coverage 91.82% 91.83% +<.01%
==========================================
Files 175 175
Lines 52551 52531 -20
==========================================
- Hits 48256 48240 -16
+ Misses 4295 4291 -4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26008 +/- ##
==========================================
+ Coverage 91.82% 91.83% +<.01%
==========================================
Files 175 175
Lines 52540 52517 -23
==========================================
- Hits 48247 48228 -19
+ Misses 4293 4289 -4
Continue to review full report at Codecov.
|
can you merge master |
@@ -27,7 +26,7 @@ def test_repr_binary_type(): | |||
raw = bytes(letters, encoding=cf.get_option('display.encoding')) | |||
except TypeError: | |||
raw = bytes(letters) | |||
b = str(compat.bytes_to_str(raw)) | |||
b = str(raw.decode('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.
not a big deal, but is the str
still necessary?
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.
Probably not...should test in a separate commit nonetheless.
pandas/tests/io/json/test_ujson.py
Outdated
@@ -654,7 +654,7 @@ def test_decode_big_escape(self): | |||
# Make sure no Exception is raised. | |||
for _ in range(10): | |||
base = '\u00e5'.encode("utf-8") | |||
quote = compat.str_to_bytes("\"") | |||
quote = b"\"" |
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.
would b'"'
be clearer by avoiding the backslash?
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 would think so.
@jreback rebased+green |
I think these are flaky tests. They pass locally for me and don't relate to changes this PR makes.
|
yeah have seen these and can’t repro either |
thanks @mroeschke |
xref CLN: remove PY2 #25725
tests added / passed
passes
git diff upstream/master -u -- "*.py" | flake8 --diff
Import
from pandas.compat.chainmap import DeepChainMap
directly where usedRemoved
isidentifier
,str_to_bytes
,bytes_to_str
,bind_method