Skip to content

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

Merged

Conversation

roberthdevries
Copy link
Contributor

Now no more warnings

@jbrockmendel
Copy link
Member

perf impact?

@roberthdevries
Copy link
Contributor Author

roberthdevries commented Apr 2, 2020

None, i reran the asv benchmark

@WillAyd
Copy link
Member

WillAyd commented Apr 2, 2020

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@WillAyd
Copy link
Member

WillAyd commented Apr 3, 2020

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 except NULL in the signature not solve the same thing?

@WillAyd WillAyd added the CI Continuous Integration label Apr 3, 2020
@roberthdevries roberthdevries force-pushed the fix-32951-suppress-exception-properly branch from 9d5a228 to 7fd9d1f Compare April 19, 2020 13:00
@roberthdevries
Copy link
Contributor Author

This fix should be more to your liking. It handles the exception exactly at the level where it is supposed to be handled.
Rerunning the asv benchmarks tells me that there are no significant changes.

@jreback jreback added this to the 1.1 milestone Apr 19, 2020
PyErr_Clear()
try:
v = get_c_string(<str>val)
except UnicodeEncodeError:
Copy link
Contributor

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)

Copy link
Contributor Author

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

@jreback jreback added the IO CSV read_csv, to_csv label Apr 21, 2020
@jreback
Copy link
Contributor

jreback commented Apr 21, 2020

@jbrockmendel

@jbrockmendel
Copy link
Member

@WillAyd does this address your concern here? If so, LGTM.

@WillAyd
Copy link
Member

WillAyd commented Apr 21, 2020

Yea this looks good very nicely done. I think good to merge @jreback

@jreback jreback merged commit 921d010 into pandas-dev:master Apr 28, 2020
@jreback
Copy link
Contributor

jreback commented Apr 28, 2020

thanks @roberthdevries very nice. don't need a whatsnew note here as this is pretty much internal.

@roberthdevries roberthdevries deleted the fix-32951-suppress-exception-properly branch May 28, 2020 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: Exception ignored in: 'pandas._libs.tslibs.util.get_c_string_buf_and_size'
4 participants