[New-bugs-announce] [issue39796] warning extension module inited twice in python3.9

hai shi report at bugs.python.org
Sat Feb 29 08:03:37 EST 2020


New submission from hai shi <shihai1991 at 126.com>:

In master branch, `_PyWarnings_Init()` have been called twice.
```
(gdb) bt
#0  _PyWarnings_Init () at Python/_warnings.c:1338
#1  0x0000000000525df3 in pycore_init_import_warnings (tstate=tstate at entry=0x9a19c0, sysmod=0x7ffff7f7e5f0) at Python/pylifecycle.c:680
...
Breakpoint 1, _PyWarnings_Init () at Python/_warnings.c:1338
1338    {
(gdb) bt
#0  _PyWarnings_Init () at Python/_warnings.c:1338
#1  0x0000000000511aac in _imp_create_builtin (module=<optimized out>, spec=0x7ffff7f2e7d0) at Python/import.c:1293
```

but in 2.7 branch, '_PyWarnings_Init()':
```
Breakpoint 1, _PyWarnings_Init() at Python/_warnings.c:886
886         m = Py_InitModule3(MODULE_NAME, warnings_functions, warnings__doc__);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.4.x86_64
(gdb) bt
#0  _PyWarnings_Init () at Python/_warnings.c:886
#1  0x00000000004fc4db in Py_InitializeEx (install_sigs=1) at Python/pythonrun.c:242
#2  0x00000000004fcb03 in Py_Initialize () at Python/pythonrun.c:370
#3  0x00000000004154fd in Py_Main (argc=1, argv=0x7fffffffe428) at Modules/main.c:505
#4  0x00000000004145f0 in main (argc=1, argv=0x7fffffffe428) at ./Modules/python.c:23
```

Why? because pylifecycle.c and _imp extension module will call `_PyWarnings_Init()`.

isn't it?

----------
components: Extension Modules
messages: 362980
nosy: brett.cannon, shihai1991
priority: normal
severity: normal
status: open
title: warning extension module inited twice in python3.9
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39796>
_______________________________________


More information about the New-bugs-announce mailing list