[New-bugs-announce] [issue42858] Incorrect return value for os.system() in recognizing import error

Xinmeng Xia report at bugs.python.org
Thu Jan 7 06:54:25 EST 2021


New submission from Xinmeng Xia <xiaxm at smail.nju.edu.cn>:

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

----------
components: Library (Lib)
files: test_zipfile.py
messages: 384582
nosy: xxm
priority: normal
severity: normal
status: open
title: Incorrect return value for os.system() in recognizing import error
versions: Python 3.10
Added file: https://bugs.python.org/file49726/test_zipfile.py

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


More information about the New-bugs-announce mailing list