This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect return value for os.system() in recognizing import error
Type: compile error Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, vstinner, xxm
Priority: normal Keywords:

Created on 2021-01-07 11:54 by xxm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_zipfile.py xxm, 2021-01-07 11:54
Messages (3)
msg384582 - (view) Author: Xinmeng Xia (xxm) Date: 2021-01-07 11:54
Running attached "test_zipfile.py" on Python 3.10 will lead to the following error messages:
----------------------------------------------------------------------------------------------------
Exception ignored in: <generator object temp_dir at 0x7f13f30ff2e0>
Traceback (most recent call last):
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <generator object temp_dir at 0x7f13f30bd5f0>
Traceback (most recent call last):
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree
  File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree
ImportError: sys.meta_path is None, Python is likely shutting down
----------------------------------------------------------------------------------------------------

However, if we run this program with os.system, the return value is 0 instead of 256. 0 represent no fails in this running! This is obviously incorrect.

Reproduce:
=========================================
import os
scode = os.system('python310  test_zipfile.py')
print("The system code of this execution is:", scode)
=========================================

The expected output: "The system code of this execution is: 256"
The actual output: "The system code of this execution is: 0"

Version info:
>>python310 -V
Python 3.10.0a2
>>uname -v
16.04.1-Ubuntu SMP Fri Sep 13 09:56:18 UTC 2019
msg384587 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-01-07 13:43
The exceptions are ignored (Exception ignored in) on shutdown and therefore don't cause the interpreter to fail with an error code. Unraisable exceptions typically occur when the interpreter is mostly shut down and garbage collection, import or atexit hook is triggered as a side-effect.
msg384588 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-07 13:59
See also https://docs.python.org/dev/library/sys.html#sys.unraisablehook
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87024
2021-01-07 21:09:53gvanrossumsetstatus: open -> closed
resolution: not a bug
stage: resolved
2021-01-07 13:59:53vstinnersetnosy: + vstinner
messages: + msg384588
2021-01-07 13:43:49christian.heimessetnosy: + christian.heimes
messages: + msg384587
2021-01-07 11:54:53xxmsettype: compile error
2021-01-07 11:54:25xxmcreate