-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
fix hashing string-casting error #21187
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
pandas/tests/series/test_repr.py
Outdated
# set sys.defaultencoding to ascii, then change it back after the test | ||
enc = sys.getdefaultencoding() | ||
reload(sys) # noqa:F821 | ||
sys.setdefaultencoding('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.
there is a context manager this i think
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.
There is a context manager for locale
in pd.util.testing. Can that be used here or do you have something else in mind? (I agree it would be prettier)
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.
yes pls use that
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.
Looks like tm.set_locale
doesn't change sys.getdefaultencoding()
. I could make a new contextmanager specifically for this (which I guess would be a no-op in py3?)
Codecov Report
@@ Coverage Diff @@
## master #21187 +/- ##
==========================================
- Coverage 91.92% 91.9% -0.02%
==========================================
Files 153 153
Lines 49563 49572 +9
==========================================
+ Hits 45559 45560 +1
- Misses 4004 4012 +8
Continue to review full report at Codecov.
|
pandas/tests/series/test_repr.py
Outdated
@@ -202,6 +203,35 @@ def test_latex_repr(self): | |||
|
|||
class TestCategoricalRepr(object): | |||
|
|||
@pytest.mark.skipif(compat.PY3, reason="Decoding failure only in PY2") |
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.
we need a test for py3 as well that uses utf8 as the encoding
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.
Sure, couldn't hurt.
doc/source/whatsnew/v0.23.1.txt
Outdated
@@ -100,6 +100,7 @@ Bug Fixes | |||
- Bug in :meth:`Series.str.replace()` where the method throws `TypeError` on Python 3.5.2 (:issue: `21078`) | |||
- Bug in :class:`Timedelta`: where passing a float with a unit would prematurely round the float precision (:issue: `14156`) | |||
- Bug in :func:`pandas.testing.assert_index_equal` which raised ``AssertionError`` incorrectly, when comparing two :class:`CategoricalIndex` objects with param ``check_categorical=False`` (:issue:`19776`) | |||
- Bug in rendering :class:`Series` with ``Categorical`` dtype in rare conditions under Python 2.7 (:issue:`21002`) |
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.
can you move to 0.23.2
pandas/tests/series/test_repr.py
Outdated
# GH#21002 if len(index) > 60, sys.getdefaultencoding()=='ascii', | ||
# and we are working in PY2, then rendering a Categorical could raise | ||
# UnicodeDecodeError by trying to decode when it shouldn't | ||
from pandas.core.base import StringMixin |
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.
can import at the top
str(ser) | ||
|
||
else: | ||
# set sys.defaultencoding to ascii, then change it back after |
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.
can you make this into a context manager in pandas.util.testing
thanks! and soon enough we will blow away all PY2 code in any event! but nice patch. |
(cherry picked from commit e24da6c)
(cherry picked from commit e24da6c)
git diff upstream/master -u -- "*.py" | flake8 --diff