mirror of
https://github.com/python/cpython.git
synced 2025-11-17 17:46:45 +00:00
Issue #16261: fix bare excepts in Doc/
This commit is contained in:
parent
c38c816ea1
commit
47395617bc
3 changed files with 3 additions and 5 deletions
|
|
@ -741,9 +741,7 @@ the basis for code meeting your own specific requirements::
|
||||||
break
|
break
|
||||||
logger = logging.getLogger(record.name)
|
logger = logging.getLogger(record.name)
|
||||||
logger.handle(record) # No level or filter logic applied - just do it!
|
logger.handle(record) # No level or filter logic applied - just do it!
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except Exception:
|
||||||
raise
|
|
||||||
except:
|
|
||||||
import sys, traceback
|
import sys, traceback
|
||||||
print('Whoops! Problem:', file=sys.stderr)
|
print('Whoops! Problem:', file=sys.stderr)
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ The module defines three convenience functions and a public class:
|
||||||
t = Timer(...) # outside the try/except
|
t = Timer(...) # outside the try/except
|
||||||
try:
|
try:
|
||||||
t.timeit(...) # or t.repeat(...)
|
t.timeit(...) # or t.repeat(...)
|
||||||
except:
|
except Exception:
|
||||||
t.print_exc()
|
t.print_exc()
|
||||||
|
|
||||||
The advantage over the standard traceback is that source lines in the
|
The advantage over the standard traceback is that source lines in the
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ module. ::
|
||||||
source = input(">>> ")
|
source = input(">>> ")
|
||||||
try:
|
try:
|
||||||
exec(source, envdir)
|
exec(source, envdir)
|
||||||
except:
|
except Exception:
|
||||||
print("Exception in user code:")
|
print("Exception in user code:")
|
||||||
print("-"*60)
|
print("-"*60)
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue