gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing#130934
gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing#130934hauntsaninja merged 4 commits intopython:mainfrom
Conversation
…iblyShadowing I chose to not raise an exception here because I think it would be confusing for module attribute access to start raising something other than AttributeError if e.g. the cwd goes away Without the change in moduleobject.c ``` ./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure ... Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253. ```
|
Looks like Windows is not happy with the test trying to delete the current working directory |
colesbury
left a comment
There was a problem hiding this comment.
LGTM, assuming the CI passes
|
Thanks @hauntsaninja for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…iblyShadowing (pythonGH-130934) I chose to not raise an exception here because I think it would be confusing for module attribute access to start raising something other than AttributeError if e.g. the cwd goes away Without the change in moduleobject.c ``` ./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure ... Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253. ``` (cherry picked from commit 0a9ae5e) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
GH-130939 is a backport of this pull request to the 3.13 branch. |
…siblyShadowing (GH-130934) (#130939) gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing (GH-130934) I chose to not raise an exception here because I think it would be confusing for module attribute access to start raising something other than AttributeError if e.g. the cwd goes away Without the change in moduleobject.c ``` ./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure ... Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253. ``` (cherry picked from commit 0a9ae5e) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
|
Without the change in moduleobject.c, we sometimes end up returning NULL from
_Py_module_getattro_implwithout an exception raised.I chose to not raise an exception here because I think it would be confusing for module attribute access to start raising something other than AttributeError if e.g. the cwd goes away
_PyModule_IsPossiblyShadowingcan return-1without an exception set #130932