[New-bugs-announce] [issue35790] Correct a statement about sys.exc_info() values restoration

Géry report at bugs.python.org
Sun Jan 20 11:39:44 EST 2019


New submission from Géry <gery.ogam at 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 at python
components: Documentation
messages: 334092
nosy: docs at 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 <report at bugs.python.org>
<https://bugs.python.org/issue35790>
_______________________________________


More information about the New-bugs-announce mailing list