Emily Morehouse added the comment:

Yury, thanks for the encouragement to continue on this patch. I think it will 
be a good exercise to dive a bit deeper into Python's bytecode and put some 
knowledge to use.

I believe that tuple argument unpacking is handled appropriately, but there is 
an even further edge case where a closure is introduced. In the following, 
inspect.getargspec works for the first bit of code, but the second fails, as 
'a' is referenced outside of scope.

>>> dis.dis(lambda (a,): lambda x: x)
  1           0 LOAD_FAST                0 (.0)
              3 UNPACK_SEQUENCE          1
              6 STORE_FAST               1 (a)
              9 LOAD_CONST               1 (<code object <lambda> at 
0x10087a130, file "<stdin>", line 1>)
             12 MAKE_FUNCTION            0
             15 RETURN_VALUE
>>> dis.dis(lambda (a,): lambda x: a)
  1           0 LOAD_FAST                0 (.0)
              3 UNPACK_SEQUENCE          1
              6 STORE_DEREF              0 (a)
              9 LOAD_CLOSURE             0 (a)
             12 BUILD_TUPLE              1
             15 LOAD_CONST               1 (<code object <lambda> at 
0x10087a930, file "<stdin>", line 1>)
             18 MAKE_CLOSURE             0
             21 RETURN_VALUE

I'll keep poking at this and see where I get.

-- EM

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29354>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to