Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Description
Bug report
Bug description:
Hi, since#131802, we seetest_peg_generator
failing with the following warning:
Warning -- logging._handlerList was modified by test_peg_generatorWarning -- Before: (140617884985088, [<weakref at 0x7fe4271c8720; to 'logging._StderrHandler' at 0x7fe427ceb620>, <weakref at 0x7fe421d4d350; to 'setuptools_scm._log.AlwaysStdErrHandler' at 0x7fe420b25fd0>], [<weakref at 0x7fe4271c8720; to 'logging._StderrHandler' at 0x7fe427ceb620>])Warning -- After: (140617884985088, [<weakref at 0x7fe4271c8720; to 'logging._StderrHandler' at 0x7fe427ceb620>, <weakref at 0x7fe421d4d350; to 'setuptools_scm._log.AlwaysStdErrHandler' at 0x7fe420b25fd0>], [<weakref at 0x7fe4271c8720; to 'logging._StderrHandler' at 0x7fe427ceb620>, <weakref at 0x7fe421d4d350; to 'setuptools_scm._log.AlwaysStdErrHandler' at 0x7fe420b25fd0>])
For some reason, during the execution, second reference to the same 'setuptools_scm._log.AlwaysStdErrHandler' appears in the_handlerList
.
When I removesetuptools_scm
, the issue is gone.
Interestingly (at least to me), when I revert changes done in#131802 inlib/test/support/__init__.py
andos_helper.py
(commenting outimport logging
is enough), the issue is gone as well, so it seems like some weird side effect of the import?
I tried to track the issue and got through setuptools all the way toep.load()
infinalize_options()
which triggers the issue (see trace below).
I added some debug prints to_addHandlerRef
function, and it's apparently called only once with this handler. Though I also see a single call for thelogging._StderrHandler'
and it's there twice as well, so I am probably overlooking something...
Here is the trace from when the handler ref is being added during the test execution:
..... File"/build/cpython-3.13/Lib/test/test_peg_generator/test_c_parser.py", line131, inbuild_extension generate_parser_c_extension(grammar, Path('.'),library_dir=self.library_dir) File"/build/cpython-3.13/Tools/peg_generator/pegen/testutil.py", line107, ingenerate_parser_c_extension compile_c_extension( File"/build/cpython-3.13/Tools/peg_generator/pegen/build.py", line160, incompile_c_extension dist= Distribution({"name": extension_name,"ext_modules": [extension]}) File"/usr/lib/python3.13/vendor-packages/setuptools/dist.py", line323, in__init__ _Distribution.__init__(self, dist_attrs) File"/usr/lib/python3.13/vendor-packages/setuptools/_distutils/dist.py", line309, in__init__self.finalize_options() File"/usr/lib/python3.13/vendor-packages/setuptools/dist.py", line787, infinalize_optionsfor epinsorted(loaded,key=by_order): File"/usr/lib/python3.13/vendor-packages/setuptools/dist.py", line786, in<lambda> loaded=map(lambdae: e.load(), filtered) File"/build/cpython-3.13/Lib/importlib/metadata/__init__.py", line179, inload module= import_module(match.group('module')) File"/build/cpython-3.13/Lib/importlib/__init__.py", line88, inimport_modulereturn _bootstrap._gcd_import(name[level:], package, level) File"<frozen importlib._bootstrap>", line1387, in_gcd_import File"<frozen importlib._bootstrap>", line1360, in_find_and_load File"<frozen importlib._bootstrap>", line1310, in_find_and_load_unlocked File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"<frozen importlib._bootstrap>", line1387, in_gcd_import File"<frozen importlib._bootstrap>", line1360, in_find_and_load File"<frozen importlib._bootstrap>", line1310, in_find_and_load_unlocked File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"<frozen importlib._bootstrap>", line1387, in_gcd_import File"<frozen importlib._bootstrap>", line1360, in_find_and_load File"<frozen importlib._bootstrap>", line1331, in_find_and_load_unlocked File"<frozen importlib._bootstrap>", line935, in_load_unlocked File"<frozen importlib._bootstrap_external>", line1026, inexec_module File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"/usr/lib/python3.13/vendor-packages/setuptools_scm/__init__.py", line8, in<module>from ._configimportDEFAULT_LOCAL_SCHEME File"<frozen importlib._bootstrap>", line1360, in_find_and_load File"<frozen importlib._bootstrap>", line1331, in_find_and_load_unlocked File"<frozen importlib._bootstrap>", line935, in_load_unlocked File"<frozen importlib._bootstrap_external>", line1026, inexec_module File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"/usr/lib/python3.13/vendor-packages/setuptools_scm/_config.py", line15, in<module>from .import _log File"<frozen importlib._bootstrap>", line1415, in_handle_fromlist File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"<frozen importlib._bootstrap>", line1360, in_find_and_load File"<frozen importlib._bootstrap>", line1331, in_find_and_load_unlocked File"<frozen importlib._bootstrap>", line935, in_load_unlocked File"<frozen importlib._bootstrap_external>", line1026, inexec_module File"<frozen importlib._bootstrap>", line488, in_call_with_frames_removed File"/usr/lib/python3.13/vendor-packages/setuptools_scm/_log.py", line48, in<module> _default_handler= make_default_handler() File"/usr/lib/python3.13/vendor-packages/setuptools_scm/_log.py", line43, inmake_default_handler handler= AlwaysStdErrHandler() File"/usr/lib/python3.13/vendor-packages/setuptools_scm/_log.py", line23, in__init__super().__init__(sys.stderr) File"/build/cpython-3.13/Lib/logging/__init__.py", line1128, in__init__ Handler.__init__(self) File"/build/cpython-3.13/Lib/logging/__init__.py", line941, in__init__ _addHandlerRef(self)
All this is with Python 3.13 (latest changes), setuptools 80.3.1, setuptools_scm 8.3.1, and on Oracle Solaris, but I don't think this is necessarily platform dependent.
I also reproduced this with older setuptools 73.0.1 and setuptools_scm 8.1.0.
CPython versions tested on:
3.13
Operating systems tested on:
Other