New submission from Keepun <kee...@gmail.com>:
exec() ignores scope. Code: -------------------------- class ExecTest: def public(self): h=None exec("h='It is public'") print(h) self._private() def _private(self): h=None exec("h='It is private'", globals(), locals()) print(h) h = None exec("h='It is global'") print(h) e=ExecTest() e.public() Result -------------------------- It is global None None -------------------------- Python 3.7.10 (default, Feb 26 2021, 13:06:18) [MSC v.1916 64 bit (AMD64)] and Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] ---------- components: Interpreter Core messages: 388366 nosy: Keepun priority: normal severity: normal status: open title: exec() ignores scope. type: behavior versions: Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43448> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com