New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enum.Enum error on sys._getframe(2) #79898
Comments
sys._getframe(2) fails in the following example: code = "from enum import Enum; Enum('Animal', 'ANT BEE CAT DOG')"
code = compile(code, "<string>", "exec")
global_ns = {}
local_ls = {}
exec(code, global_ns, local_ls) Error with Python 3.7.2 (Fedora 29): Traceback (most recent call last):
File "x.py", line 5, in <module>
exec(code, global_ns, local_ls)
File "<string>", line 1, in <module>
File "/usr/lib64/python3.7/enum.py", line 311, in __call__
return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
File "/usr/lib64/python3.7/enum.py", line 429, in _create_
module = sys._getframe(2).f_globals['__name__']
KeyError: '__name__' |
The bug has been reported in my perf project: |
Looks like the following code: if module is None:
try:
module = sys._getframe(2).f_globals['__name__']
except (AttributeError, ValueError) as exc:
pass needs to have |
Marking this as "easy". It needs a test showing the failing behavior, then the fix. |
Hi, PR #11521 should fix the issue. |
That PR does not go with this issue. ;) |
It does. You removed the link to PR 11523 which is a fix for this issue. |
I was confused with PR, so here you have:
Both are merged, so I close the issue. Thanks Rémi Lapeyre for the fix! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: