[Python-checkins] cpython (2.7): Issue #20510: Confirm that the code attribute of the SystemExit

zach.ware python-checkins at python.org
Wed Feb 19 17:46:32 CET 2014


http://hg.python.org/cpython/rev/292cac3afca6
changeset: 89274:292cac3afca6
branch: 2.7
parent: 89271:857ddbaff14e
user: Zachary Ware <zachary.ware at gmail.com>
date: Wed Feb 19 10:43:13 2014 -0600
summary:
 Issue #20510: Confirm that the code attribute of the SystemExit
exception raised by sys.exit is None when no code is given.
As suggested by Serhiy Storchaka.
files:
 Lib/test/test_sys.py | 4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -119,6 +119,10 @@
 self.assertRaises(TypeError, sys.exit, 42, 42)
 
 # call without argument
+ with self.assertRaises(SystemExit) as cm:
+ sys.exit()
+ self.assertIsNone(cm.exception.code)
+
 rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()')
 self.assertEqual(rc, 0)
 self.assertEqual(out, b'')
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /