New submission from Géry <gery.o...@gmail.com>:

In the documentation of the try statement 
(https://docs.python.org/3/reference/compound_stmts.html#the-try-statement), I 
think that the sentence:

"sys.exc_info() values are restored to their previous values (before the call) 
when returning from a function that handled an exception."

should be replaced by this sentence:

"sys.exc_info() values are restored to their previous values (before the call) 
when leaving an exception handler."

as proven by this code which does not use any "function that handled an 
exception" and yet restores sys.exc_info() values:


>>> try:
...     raise ValueError
... except:
...     try:
...          raise TypeError
...     except:
...         print(sys.exc_info())
...     print(sys.exc_info())
... 
(<class 'TypeError'>, TypeError(), <traceback object at 0x10ca19bc8>)
(<class 'ValueError'>, ValueError(), <traceback object at 0x10ca19c08>)

----------
assignee: docs@python
components: Documentation
messages: 334092
nosy: docs@python, eric.araujo, ezio.melotti, maggyero, mdk, willingc
priority: normal
severity: normal
status: open
title: Correct a statement about sys.exc_info() values restoration
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35790>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to