[issue35790] Correct a statement about sys.exc_info() values restoration

New submission from Géry <gery.ogam@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 <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Change by Géry <gery.ogam@gmail.com>: ---------- keywords: +patch pull_requests: +11386 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Change by Géry <gery.ogam@gmail.com>: ---------- keywords: +patch, patch pull_requests: +11386, 11387 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Change by Géry <gery.ogam@gmail.com>: ---------- keywords: +patch, patch, patch pull_requests: +11386, 11387, 11388 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Change by Géry <gery.ogam@gmail.com>: ---------- nosy: +cheryl.sabella -eric.araujo, ezio.melotti, willingc title: Correct a statement about sys.exc_info() values restoration -> Correct the description of sys.exc_info() and add a code example type: -> enhancement versions: +Python 3.6, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Julien Palard <julien+python@palard.fr> added the comment: New changeset d515c610c61b9a8c40c037a3dc3bfc8d67563658 by Géry Ogam in branch 'master': bpo-35790: Correct the description of sys.exc_info() and add a code example (GH-11625) https://github.com/python/cpython/commit/d515c610c61b9a8c40c037a3dc3bfc8d675... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________

Change by Julien Palard <julien+python@palard.fr>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35790> _______________________________________
participants (2)
-
Géry
-
Julien Palard