[Python-checkins] cpython: Issue #16261: fix bare excepts in Doc/
andrew.svetlov
python-checkins at python.org
Fri Nov 2 21:07:38 CET 2012
http://hg.python.org/cpython/rev/b2bd62d1644f
changeset: 80184:b2bd62d1644f
user: Andrew Svetlov <andrew.svetlov at gmail.com>
date: Fri Nov 02 22:07:26 2012 +0200
summary:
Issue #16261: fix bare excepts in Doc/
files:
Doc/howto/logging-cookbook.rst | 4 +---
Doc/library/timeit.rst | 2 +-
Doc/library/traceback.rst | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
--- a/Doc/howto/logging-cookbook.rst
+++ b/Doc/howto/logging-cookbook.rst
@@ -741,9 +741,7 @@
break
logger = logging.getLogger(record.name)
logger.handle(record) # No level or filter logic applied - just do it!
- except (KeyboardInterrupt, SystemExit):
- raise
- except:
+ except Exception:
import sys, traceback
print('Whoops! Problem:', file=sys.stderr)
traceback.print_exc(file=sys.stderr)
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -151,7 +151,7 @@
t = Timer(...) # outside the try/except
try:
t.timeit(...) # or t.repeat(...)
- except:
+ except Exception:
t.print_exc()
The advantage over the standard traceback is that source lines in the
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst
--- a/Doc/library/traceback.rst
+++ b/Doc/library/traceback.rst
@@ -146,7 +146,7 @@
source = input(">>> ")
try:
exec(source, envdir)
- except:
+ except Exception:
print("Exception in user code:")
print("-"*60)
traceback.print_exc(file=sys.stdout)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list