Issue390

Title Error with handling locals() in nested functions
Priority bug Status unread
Superseder Nosy List asovetnikov
Assigned To Keywords

Created on 2017-12-15.14:37:41 by asovetnikov, last changed by asovetnikov.

Messages
msg2296 (view) Author: asovetnikov Date: 2017-12-15.14:37:39
Just have a bug with nested functions and locals():

Steps to reproduce:
main.py:
def high():
    cad = 1
    # with atomic():
    def nested1():
        a = 2
        def nested2():
            o = {}
            o['cad'] = cad
        nested2()
        print('result'.format(**locals()))
    nested1()
high()

Run:
nuitka main.py

Output:
  File "C:\Python34\lib\site-packages\nuitka\codegen\GlobalsLocalsCodes.py", line 
206, in getLoadLocalsCode
    for local_var, version in _sorted(variables):
  File "C:\Python34\lib\site-packages\nuitka\codegen\GlobalsLocalsCodes.py", line 
158, in _sorted
    key = lambda variable_desc: all_variables.index(variable_desc[0]),
  File "C:\Python34\lib\site-packages\nuitka\codegen\GlobalsLocalsCodes.py", line 
158, in <lambda>
    key = lambda variable_desc: all_variables.index(variable_desc[0]),
ValueError: tuple.index(x): x not in tuple

nuitka --version
0.5.28.1

Seems cad variable is treated as local to nested2(), but it is not in local variables 
list when sorting.
History
Date User Action Args
2017-12-15 14:37:41asovetnikovcreate