-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
_zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure #87145
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
Comments
_zoneinfo starts with: static int
zoneinfomodule_exec(PyObject *m)
{
PyDateTime_IMPORT; with: #define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
#define PyDateTime_IMPORT \
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) If PyCapsule_Import() fails, zoneinfomodule_exec() returns 0 (success) with an exception raised. It should check if the import succeeded or not. Concrete example on AIX where datetime cannot be imported: "./python setup.py build" fails with: Assertion failed: (item != NULL) ^ (PyErr_Occurred() != NULL), file Objects/abstract.c, line 163 -- By the way, the import machinery should raise a SystemError if a module exec function raises an exception *and* reports a success: see _Py_CheckFunctionResult(). |
Why not return -1 directly when PyCapsule_Import() fails? |
That would work. I opened an issue since there is a bug. |
Thanks for the fix Hai Shi!
It's already the case. Example: >>> import _zoneinfo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: execution of module _zoneinfo raised unreported exception With this bug: diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index d0c462fb86..fc564b9587 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2683,6 +2683,7 @@ zoneinfomodule_exec(PyObject *m)
goto error;
}
+ PyErr_SetString(PyExc_Exception, "BUG");
return 0;
error: |
Nice, interesting case. |
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: