Pablo Galindo Salgado <pablog...@gmail.com> added the comment:
>>> code2 = """\ ... def foo(): ... x = 42 ... def bar(): ... return -1 ... """ >>> top.get_children()[0] <Function SymbolTable for foo in ?> >>> top = symtable.symtable(code2, "?", "exec") >>> top.get_children()[0].lookup('x')._Symbol__scope == symtable.LOCAL True but if we return x from bar: That fix is not correct. For instance consider: >>> code = """\ ... def foo(): ... x = 42 ... def bar(): ... return x ... """ >>> import symtable >>> top = symtable.symtable(code, "?", "exec") >>> top.get_children()[0].lookup('x')._Symbol__scope == symtable.LOCAL False ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40196> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com