summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-09 00:43:21 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-02-09 00:43:21 (GMT)
commitd979e4335d02bee7301c2b2dec61fe2155fbae98 (patch)
tree03a43ccec3f7109d73c48f3782500be9c6579be5 /Lib/test/test_cmd_line_script.py
parentc9d1a6b85eb9cb1ddd520cefc5f0c7a21a1b1e2c (diff)
downloadcpython-d979e4335d02bee7301c2b2dec61fe2155fbae98.zip
cpython-d979e4335d02bee7301c2b2dec61fe2155fbae98.tar.gz
cpython-d979e4335d02bee7301c2b2dec61fe2155fbae98.tar.bz2
Close #20500: Don't trigger PyObject_Str assertion at shutdown
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 03c071e..1e6746d 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -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)