Closed
Description
The test_concurrency() of test_import fails randomly on sys.settrace(). Example:
$ ./python -m test test_import -m test_concurrency -v -j30 -F --fail-env-changed (...) 0:00:13 load avg: 12.46 [ 97/1] test_import failed (env changed) test_concurrency (test.test_import.ImportTests) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.487s OK Warning -- Uncaught thread exception: RuntimeError Exception in thread Thread-13 (run): Traceback (most recent call last): File "/home/vstinner/python/3.10/Lib/threading.py", line 1016, in _bootstrap_inner self.run() File "/home/vstinner/python/3.10/Lib/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/home/vstinner/python/3.10/Lib/test/test_import/__init__.py", line 457, in run sys.settrace(None) RuntimeError: Cannot install a trace function while another trace function is being installed (...)
The problem is that the _PyEval_SetTrace() function fails with RuntimeError("Cannot install a trace function while another trace function is being installed") on Py_XDECREF(traceobj);
indirectly calls sys.settrace()
.
IMO Py_XDECREF(traceobj);
should be called after reentrant = 0;
, at the end of the function.