-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Use try/except block to properly catch and handle the exception #33235
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
TST: Use try/except block to properly catch and handle the exception #33235
Conversation
perf impact? |
None, i reran the asv benchmark |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Hmm not sure about this approach though; typically you do want to pass along the error to the caller rather than swallowing ref https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#error-return-values does |
Now no more warnings
9d5a228
to
7fd9d1f
Compare
This fix should be more to your liking. It handles the exception exactly at the level where it is supposed to be handled. |
PyErr_Clear() | ||
try: | ||
v = get_c_string(<str>val) | ||
except UnicodeEncodeError: |
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.
do we have anything in the test suite that hits this now? (if we do can you add this issue number there)
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.
This issue was triggered by the following test: pandas/tests/frame/test_api.py::test_column_name_contains_unicode_surrogate
Which was added because of a fix for #25509
Yea this looks good very nicely done. I think good to merge @jreback |
thanks @roberthdevries very nice. don't need a whatsnew note here as this is pretty much internal. |
Now no more warnings
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff