[issue35717] enum.Enum error on sys._getframe(2)

STINNER Victor report at bugs.python.org
Fri Jan 11 10:08:15 EST 2019


New submission from STINNER Victor <vstinner at redhat.com>:

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__'

----------
components: Library (Lib)
messages: 333474
nosy: barry, eli.bendersky, ethan.furman, vstinner
priority: normal
severity: normal
status: open
title: enum.Enum error on sys._getframe(2)
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35717>
_______________________________________


More information about the Python-bugs-list mailing list