[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-29 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a6192635f1e62af2bb8a435487ebb51800edd671 by Victor Stinner in 
branch 'master':
bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)
https://github.com/python/cpython/commit/a6192635f1e62af2bb8a435487ebb51800edd671


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23180
pull_request: https://github.com/python/cpython/pull/24356

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67 by Victor Stinner in 
branch 'master':
bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)
https://github.com/python/cpython/commit/c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67


--
nosy: +Mark.Shannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread hai shi


hai shi  added the comment:

> It's already the case. Example

Nice, interesting case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 895591c1f0bdec5ad357fe6a5fd0875990061357 by Miss Islington (bot) 
in branch '3.9':
bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure 
(GH-24333) (GH-24351)
https://github.com/python/cpython/commit/895591c1f0bdec5ad357fe6a5fd0875990061357


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23172
pull_request: https://github.com/python/cpython/pull/24352

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for the fix Hai Shi!

> 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().

It's already the case. Example:

>>> import _zoneinfo
Traceback (most recent call last):
  File "", line 1, in 
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:

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +23171
pull_request: https://github.com/python/cpython/pull/24351

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset eeb701adc0fc29ba803fddf133d917ff45639a00 by Hai Shi in branch 
'master':
bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure 
(GH-24333)
https://github.com/python/cpython/commit/eeb701adc0fc29ba803fddf133d917ff45639a00


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-25 Thread hai shi


Change by hai shi :


--
keywords: +patch
pull_requests: +23152
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24333

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Why not return -1 directly when PyCapsule_Import() fails?

That would work.

I opened an issue since there is a bug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-23 Thread hai shi


hai shi  added the comment:

> If PyCapsule_Import() fails, zoneinfomodule_exec() returns 0 (success) with 
> an exception raised.

Why not return -1 directly when PyCapsule_Import() fails?
It looks like more simpler. Do I miss something?

--
nosy: +shihai1991

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-20 Thread STINNER Victor


New submission from STINNER Victor :

_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:
https://bugs.python.org/issue42604#msg385347

"./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().

--
components: Extension Modules
messages: 385355
nosy: vstinner
priority: normal
severity: normal
status: open
title: _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT 
failure
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com