Created
June 26, 2020 07:08
-
-
Save mahmoud/1f8a62aaaad9e178594c7d60dfa9e1d9 to your computer and use it in GitHub Desktop.
python3 exception var deleting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python3 | |
Python 3.7.7 (default, Mar 10 2020, 17:25:08) | |
[GCC 5.4.0 20160609] on linux | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> e = 'hi' | |
>>> try: | |
... 1/0 | |
... except Exception as e: | |
... pass | |
... | |
>>> e | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
NameError: name 'e' is not defined | |
>>> | |
""" | |
What might first be understood as a scoping improvement in python3 was | |
actually a side effect of adding traceback references to exceptions, and | |
yields this funky variable name deletion issue. It's all to avoid memory leaks | |
(e.g., when you catch an exception at the module level) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment