Bug report
Bug description:
There is an unexpected SystemError which is completely outside of user code. I get it with Python 3.13.0 on Windows, but did never see it with Python 3.12.x:
Exception ignored on threading shutdown:
Traceback (most recent call last):
File "C:\Program Files\Python313\Lib\threading.py", line 1524, in _shutdown
if _main_thread._handle.is_done() and _is_main_interpreter():
SystemError: <method 'is_done' of '_thread._ThreadHandle' objects> returned a result with an exception set
Reproduction
The following minimal reproduction script:
import asyncio
import sys
async def run():
p = await asyncio.create_subprocess_exec(*["ssh", "mek@192.168.37.128"])
try:
return await p.wait() # leaving out "return" would help
finally:
if p.returncode is None: # leaving out this "if" statement or the complete "finally" block also would help
p.terminate()
sys.exit(asyncio.run(run()))
Run the it and leave the ssh session with sudo reboot now. You get the following output (note the last 5 lines):
mek@mek-ubuntu:~$ sudo reboot now
[sudo] password for mek:
Broadcast message from root@mek-ubuntu on pts/1 (Tue 2024-10-22 15:55:11 CEST):
The system will reboot now!
mek@mek-ubuntu:~$ Connection to 192.168.37.128 closed by remote host.
Connection to 192.168.37.128 closed.
Exception ignored on threading shutdown:
Traceback (most recent call last):
File "C:\Program Files\Python313\Lib\threading.py", line 1524, in _shutdown
if _main_thread._handle.is_done() and _is_main_interpreter():
SystemError: <method 'is_done' of '_thread._ThreadHandle' objects> returned a result with an exception set
There seems to be a strange interaction with async functions, local variables and return values:
- leaving out the "return" keyword at
return await p.wait() prevents the warning message
- leaving out the "finally" block or just leave it empty with
pass also omits the warning message
- exiting the SSH session with
exit also omits the warning message
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
Bug report
Bug description:
There is an unexpected SystemError which is completely outside of user code. I get it with Python 3.13.0 on Windows, but did never see it with Python 3.12.x:
Reproduction
The following minimal reproduction script:
Run the it and leave the ssh session with
sudo reboot now. You get the following output (note the last 5 lines):There seems to be a strange interaction with async functions, local variables and return values:
return await p.wait()prevents the warning messagepassalso omits the warning messageexitalso omits the warning messageCPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
sys.exit(0xffff_ffff)on Windows #125896sys.exit(0xffff_ffff)on Windows (GH-125896) #125925