Author vstinner
Recipients barry, eli.bendersky, ethan.furman, vstinner
Date 2019-01-11.15:08:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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 "", line 5, in <module>
    exec(code, global_ns, local_ls)
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.7/", line 311, in __call__
    return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
  File "/usr/lib64/python3.7/", line 429, in _create_
    module = sys._getframe(2).f_globals['__name__']
KeyError: '__name__'
Date User Action Args
2019-01-11 15:08:17vstinnersetrecipients: + vstinner, barry, eli.bendersky, ethan.furman
2019-01-11 15:08:13vstinnersetmessageid: <>
2019-01-11 15:08:13vstinnerlinkissue35717 messages
2019-01-11 15:08:13vstinnercreate