Skip to content

Tuple unpacking to local variables should be allowed #65

@tseaver

Description

@tseaver

E.g., from the Products.PythonScripts fibonacci test:

l = []
a, b = 0, 1
while b < 100000000:
    l.append(b)
    a, b = b, a+b  # fails with error
return l

The error is:

> /home/tseaver/.buildout/eggs/cp27m/RestrictedPython-4.0a1-py2.7.egg/RestrictedPython/tests/verify.py(45)verify()
-> verify(ob)
(Pdb) d
> /home/tseaver/.buildout/eggs/cp27m/RestrictedPython-4.0a1-py2.7.egg/RestrictedPython/tests/verify.py(42)verify()
-> verifycode(code)
(Pdb) d
> /home/tseaver/.buildout/eggs/cp27m/RestrictedPython-4.0a1-py2.7.egg/RestrictedPython/tests/verify.py(50)verifycode()
-> _verifycode(code)
(Pdb) d
> /home/tseaver/.buildout/eggs/cp27m/RestrictedPython-4.0a1-py2.7.egg/RestrictedPython/tests/verify.py(110)_verifycode()
-> (code.co_filename, line))
(Pdb) l
105  	            if not (window[0].opname == "CALL_FUNCTION" and
106  	                    window[1].opname == "ROT_TWO" and
107  	                    window[2].opname == "LOAD_GLOBAL" and
108  	                    window[2].arg == "_getiter_"):
109  	                raise ValueError("unguarded unpack sequence at %s:%d" %
110  ->	                                 (code.co_filename, line))
111  	
112  	        # should check CALL_FUNCTION_{VAR,KW,VAR_KW} but that would
113  	        # require a potentially unlimited history.  need to refactor
114  	        # the "window" before I can do that.
115  	

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions