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
Clean up path_converter in posixmodule.c #70858
Comments
path_converter in Modules/posixmodule.c sequentially tries to convert an argument to str, bytes, and int. If previous conversion is failed, it clears the error and tries with type. This can hide some errors (such as MemoryError) and even cause using unexpected conversion. Proposed patch cleans up path_converter. In addition it avoids copying the content of instances of string subclass. |
I approve in principle, but this patch isn't ready. If we compile on Win32, and allow_fd is on, and they pass in an invalid fd, your patched code will reach line 914 "length = PyBytes_GET_SIZE(bytes);" but bytes will be uninitialized. |
Good catch! Here is updated patch. It fixes also hiding exception in dir_fd converter. |
Can you post the updated patch please? |
Here it is. |
LGTM. |
New changeset a866f5727b7f by Serhiy Storchaka in branch 'default': |
Thank you for your review Larry. |
New changeset 8dc144e47252 by Serhiy Storchaka in branch 'default': |
New changeset 4acdb324a430 by Serhiy Storchaka in branch 'default': |
Looks like the tests may need updating for a changed exception message: http://buildbot.python.org/all/builders/x86%20Ubuntu%20Shared%203.x/builds/12996/steps/test/logs/stdio During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_posix.py", line 415, in test_stat
posix.stat, None)
AssertionError: "can't specify None for path argument" does not match "stat: path should be string, bytes or integer, not NoneType" ====================================================================== During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_posix.py", line 867, in test_stat_dir_fd
posix.stat, support.TESTFN, dir_fd=posix.getcwd())
AssertionError: "should be integer, not" does not match "argument should be integer or None, not str" |
New changeset 633bb190fb76 by Serhiy Storchaka in branch 'default': |
Thank you Martin. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: