[pypy-commit] pypy py3.3-fixes2: sys.exit() should produce a SystemExit with code is None

numerodix noreply at buildbot.pypy.org
Wed Aug 13 00:20:11 CEST 2014


Author: Martin Matusiak <numerodix at gmail.com>
Branch: py3.3-fixes2
Changeset: r72775:4558aef78acc
Date: 2014-08-12 21:34 +0200
http://bitbucket.org/pypy/pypy/changeset/4558aef78acc/

Log:	sys.exit() should produce a SystemExit with code is None

diff --git a/pypy/module/exceptions/test/test_exc.py b/pypy/module/exceptions/test/test_exc.py
--- a/pypy/module/exceptions/test/test_exc.py
+++ b/pypy/module/exceptions/test/test_exc.py
@@ -127,6 +127,24 @@
         assert SystemExit("x").code == "x"
         assert SystemExit(1, 2).code == (1, 2)
 
+    def test_sys_exit(self):
+        import sys
+
+        exc = raises(SystemExit, sys.exit)
+        assert exc.value.code is None
+
+        exc = raises(SystemExit, sys.exit, 0)
+        assert exc.value.code == 0
+
+        exc = raises(SystemExit, sys.exit, 1)
+        assert exc.value.code == 1
+
+        exc = raises(SystemExit, sys.exit, 2)
+        assert exc.value.code == 2
+
+        exc = raises(SystemExit, sys.exit, (1, 2, 3))
+        assert exc.value.code == (1, 2, 3)
+
     def test_str_unicode(self):
         e = ValueError('àèì')
         assert str(e) == 'àèì'
diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py
--- a/pypy/module/sys/app.py
+++ b/pypy/module/sys/app.py
@@ -49,7 +49,7 @@
     except:
         return False    # got an exception again... ignore, report the original
 
-def exit(exitcode=0):
+def exit(exitcode=None):
     """Exit the interpreter by raising SystemExit(exitcode).
 If the exitcode is omitted or None, it defaults to zero (i.e., success).
 If the exitcode is numeric, it will be used as the system exit status.


More information about the pypy-commit mailing list