[Ironpython-users] Differences with pyc-compiled assemblies?
Jeff Hardy
jdhardy at gmail.com
Mon Nov 12 17:05:26 CET 2012
On Mon, Nov 12, 2012 at 2:03 AM, Nicholas Devenish <misnomer at gmail.com> wrote:
> Hi Jeff again,
>
>> In inspect.py, just before line 758, it looks at co.co_argcount and
>> co.co_varnames and assumes that they are the same length, but my guess
>> is that they might not be when compiled with pyc. If you can figure
>> out exactly what getargspec is being called on, that might help make a
>> simpler reproduction that I can work off of.
>
>
> I spent some time this morning trying to reduce down to a standalone test case; I've got it down to the following, and don't understand what is going wrong so can't work out what else to remove; sorry about the large chain of functions, but it seems to somehow be involved. I hope it is helpful:
>
>> from functools import update_wrapper
>> import inspect
>>
>> def decorator(target):
>> def decorate(fn):
>> return inspect.getargspec(fn)
>> return update_wrapper(decorate, target)
>>
>> def _decorate_with_warning(func):
>> @decorator
>> def warned(fn):
>> pass
>> warned(func)
>>
>> @_decorate_with_warning
>> def execute_at(self, event_name, target):
>> def call_event(target, connection):
>> if self._somefun(event_name, target, connection):
>> pass
>
> As before, it runs fine as a standalone script
> $ ipy testipy.py
>
> But compiling with:
>> pyc /out:TestIPy testily.py
>> ipy
>>> import clr
>>> clr.AddReferenceToFileAndPath("TestIPy.dll")
>>> import testipy
>
> Gives the same traceback:
>> Traceback (most recent call last):
>> File "runtest.py", line 3, in <module>
>> File "testipy", line 3, in <module>
>> File "testipy", line 14, in _decorate_with_warning
>> File "testipy", line 7, in decorate
>> File "c:\Program Files\IronPython 2.7\Lib\inspect.py", line 820, in getargspec
>> File "c:\Program Files\IronPython 2.7\Lib\inspect.py", line 762, in getargs
>> IndexError: index out of range: 2
>
> I hope this is helpful!
Very, thank you. Do you think you could open an issue
(http://ironpython.codeplex.com/WorkItem/Create) and put the smaller
repro in it? I'll try to take a look at it soon because I'm working on
the compiler code anyway, but at least with an issue it won't get
completely forgotten.
- Jeff
More information about the Ironpython-users
mailing list