-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG: read_csv: fix wrong exception on permissions issue #32737
BUG: read_csv: fix wrong exception on permissions issue #32737
Conversation
Will add tests and whatsnew later, for now curious if it passes the windows build. |
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.
cool thanks. Would be nice to get green
pandas/_libs/src/parser/io.c
Outdated
@@ -62,6 +66,11 @@ void *new_file_source(char *fname, size_t buffer_size) { | |||
#endif | |||
if (fs->fd == -1) { | |||
free(fs); | |||
#ifdef USE_WIN_UTF16 |
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.
Is this not applicable to the above calls? If it is you can just make a macro for it in portable.h
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 removed the special case handling for Windows. I checked the python code and PyErr_SetFromErrnoWithFilename works also in Windows
a9393e9
to
ffcc4f6
Compare
os.chmod(path, 0) # make file unreadable | ||
with pytest.raises(PermissionError, match=msg) as e: | ||
parser.read_csv(path) | ||
assert path == e.value.filename |
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 think this assertion needs to be un-indented
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.
You are absolutely right and the test before this one had the same issue (I copied it from that test). That one is fixed as well.
Get rid of all error printf's and produce proper Python exceptions
PyErr_SetFromErrnoWithFilename works for Unix and Windows
3f29d8d
to
f14b501
Compare
@gfyoung if any comments. |
Co-Authored-By: gfyoung <gfyoung17+GitHub@gmail.com>
…2737) * Generate exception from the C code in the proper manner Get rid of all error printf's and produce proper Python exceptions * Declare some more exceptions from C code * Remove special case error message for c parser * Add whatsnew entry * Fix missing semicolons * Add regression test * Remove special case handling for Windows PyErr_SetFromErrnoWithFilename works for Unix and Windows * Remove call to GetLastError(), when using 0, the python error code handles this * black fixes * Fix indentation of assert statement (also in previous test, same error) * Skip the test on windows * Fix black issue * Let new_mmap fail without exception to allow fallback * Do not create a python error in new_mmap to allow the fallback to work silently * Remove the NULL pointer check for new_rd_source now that it will raise an exception * Update doc/source/whatsnew/v1.1.0.rst Co-Authored-By: gfyoung <gfyoung17+GitHub@gmail.com> Co-authored-by: Jeff Reback <jeff@reback.net> Co-authored-by: gfyoung <gfyoung17+GitHub@gmail.com>
…2737) * Generate exception from the C code in the proper manner Get rid of all error printf's and produce proper Python exceptions * Declare some more exceptions from C code * Remove special case error message for c parser * Add whatsnew entry * Fix missing semicolons * Add regression test * Remove special case handling for Windows PyErr_SetFromErrnoWithFilename works for Unix and Windows * Remove call to GetLastError(), when using 0, the python error code handles this * black fixes * Fix indentation of assert statement (also in previous test, same error) * Skip the test on windows * Fix black issue * Let new_mmap fail without exception to allow fallback * Do not create a python error in new_mmap to allow the fallback to work silently * Remove the NULL pointer check for new_rd_source now that it will raise an exception * Update doc/source/whatsnew/v1.1.0.rst Co-Authored-By: gfyoung <gfyoung17+GitHub@gmail.com> Co-authored-by: Jeff Reback <jeff@reback.net> Co-authored-by: gfyoung <gfyoung17+GitHub@gmail.com>
…2737) * Generate exception from the C code in the proper manner Get rid of all error printf's and produce proper Python exceptions * Declare some more exceptions from C code * Remove special case error message for c parser * Add whatsnew entry * Fix missing semicolons * Add regression test * Remove special case handling for Windows PyErr_SetFromErrnoWithFilename works for Unix and Windows * Remove call to GetLastError(), when using 0, the python error code handles this * black fixes * Fix indentation of assert statement (also in previous test, same error) * Skip the test on windows * Fix black issue * Let new_mmap fail without exception to allow fallback * Do not create a python error in new_mmap to allow the fallback to work silently * Remove the NULL pointer check for new_rd_source now that it will raise an exception * Update doc/source/whatsnew/v1.1.0.rst Co-Authored-By: gfyoung <gfyoung17+GitHub@gmail.com> Co-authored-by: Jeff Reback <jeff@reback.net> Co-authored-by: gfyoung <gfyoung17+GitHub@gmail.com>
Get rid of all error printf's and produce proper Python exceptions
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff