mirror of
https://github.com/python/cpython.git
synced 2025-09-02 06:57:58 +00:00
Close #20500: Don't trigger PyObject_Str assertion at shutdown
This commit is contained in:
parent
c9d1a6b85e
commit
d979e4335d
4 changed files with 28 additions and 2 deletions
|
@ -405,6 +405,24 @@ class CmdLineTest(unittest.TestCase):
|
|||
'stdout=%r stderr=%r' % (stdout, stderr))
|
||||
self.assertEqual(0, rc)
|
||||
|
||||
def test_issue20500_exit_with_exception_value(self):
|
||||
script = textwrap.dedent("""\
|
||||
import sys
|
||||
error = None
|
||||
try:
|
||||
raise ValueError('some text')
|
||||
except ValueError as err:
|
||||
error = err
|
||||
|
||||
if error:
|
||||
sys.exit(error)
|
||||
""")
|
||||
with temp_dir() as script_dir:
|
||||
script_name = _make_test_script(script_dir, 'script', script)
|
||||
exitcode, stdout, stderr = assert_python_failure(script_name)
|
||||
text = stderr.decode('ascii')
|
||||
self.assertEqual(text, "some text")
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(CmdLineTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue