[Python-checkins] bpo-38059: Using sys.exit() over exit() in inspect.py (GH-15666)

Miss Islington (bot) webhook-mailer at python.org
Mon Sep 9 11:20:40 EDT 2019


https://github.com/python/cpython/commit/0d4396c04cba5ac2b66fdaa23c01db84b1b54227
commit: 0d4396c04cba5ac2b66fdaa23c01db84b1b54227
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-09-09T08:20:36-07:00
summary:

bpo-38059: Using sys.exit() over exit() in inspect.py (GH-15666)


Constants added by the site module like exit() "should not be used in programs"
(cherry picked from commit e3c59a75279b0df4e7553d6f0031e202de434e43)

Co-authored-by: Alan Yee <alanyee at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2019-09-08-11-36-50.bpo-38059.8SA6co.rst
M Lib/inspect.py

diff --git a/Lib/inspect.py b/Lib/inspect.py
index a616f2d49b7d..0a57749ccdd4 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -3118,7 +3118,7 @@ def _main():
                                                     type(exc).__name__,
                                                     exc)
         print(msg, file=sys.stderr)
-        exit(2)
+        sys.exit(2)
 
     if has_attrs:
         parts = attrs.split(".")
@@ -3128,7 +3128,7 @@ def _main():
 
     if module.__name__ in sys.builtin_module_names:
         print("Can't get info for builtin modules.", file=sys.stderr)
-        exit(1)
+        sys.exit(1)
 
     if args.details:
         print('Target: {}'.format(target))
diff --git a/Misc/NEWS.d/next/Library/2019-09-08-11-36-50.bpo-38059.8SA6co.rst b/Misc/NEWS.d/next/Library/2019-09-08-11-36-50.bpo-38059.8SA6co.rst
new file mode 100644
index 000000000000..001952ae1261
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-09-08-11-36-50.bpo-38059.8SA6co.rst
@@ -0,0 +1 @@
+inspect.py now uses sys.exit() instead of exit()



More information about the Python-checkins mailing list