From: Andrew Svetlov Date: Fri, 2 Nov 2012 20:07:26 +0000 (+0200) Subject: Issue #16261: fix bare excepts in Doc/ X-Git-Tag: v3.4.0a1~2107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47395617bc2a6d2188039bf30e637bc203f93aba;p=python Issue #16261: fix bare excepts in Doc/ --- diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst index 92af0ec585..b336a4ad8a 100644 --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -741,9 +741,7 @@ the basis for code meeting your own specific requirements:: 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 index a487917924..0cc15868db 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -151,7 +151,7 @@ The module defines three convenience functions and a public class: 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 index 32e57337fa..0533beaf8c 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -146,7 +146,7 @@ module. :: source = input(">>> ") try: exec(source, envdir) - except: + except Exception: print("Exception in user code:") print("-"*60) traceback.print_exc(file=sys.stdout)