classification
Title: Correct a statement about sys.exc_info() values restoration
Type: Stage: patch review
Components: Documentation Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, ezio.melotti, maggyero, mdk, willingc
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-20 16:39 by maggyero, last changed 2019-01-20 16:56 by maggyero.

Pull Requests
URL Status Linked Edit
PR 11625 open maggyero, 2019-01-20 16:56
PR 11625 open maggyero, 2019-01-20 16:56
PR 11625 open maggyero, 2019-01-20 16:56
Messages (1)
msg334092 - (view) Author: Géry (maggyero) * Date: 2019-01-20 16:39
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>)
History
Date User Action Args
2019-01-20 16:57:10maggyerosetkeywords: + patch
stage: patch review
pull_requests: + pull_request11388
2019-01-20 16:57:02maggyerosetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11387
2019-01-20 16:56:50maggyerosetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11386
2019-01-20 16:39:44maggyerocreate