5

Closed

Too many arguments supplied to a variadic function causes clr.CompileModules to fail

description

Supplying 13 arguments to a Python function taking variable arguments causes a clr.CompileModules failure; 12 arguements compiles fine. The failure message is:
 
SystemError: Unable to make a reference to a transient module from a non-transient module.
 
This first sample program works fine with 12 arguments to the variadic function:
 

Varargs1.py:

def Varargs( arg, *args, **kwargs ):
return "arg: %s\nargs: %s\nkwargs: %s" % ( arg, repr( args ), repr( kwargs ))
 

print Varargs( 'a', 1,2,3,4,5,6,7,8,9,10,11,12 )

 
Compiling successfully using pyc.py (which basically just invokes clr.CompileModule:
 
C:> ipy pyc.py /target:exe /main:Varargs1.py Varargs1.py
Input Files:
Varargs1.py
Output:
Varargs1
Target:
ConsoleApplication
Platform:
ILOnly
Machine:
I386
Compiling...
Saved to Varargs
 
C:>Varargs1
arg: a
args: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
kwargs: {}
 
 
 
Adding one more argument (totalling 13) to the Varargs function call causes a clr.CompileModules failure:
 

Varargs2.py:

def Varargs( arg, *args, **kwargs ):
return "arg: %s\nargs: %s\nkwargs: %s" % ( arg, repr( args ), repr( kwargs ))
 

print Varargs( 'a', 1,2,3,4,5,6,7,8,9,10,11,12,13 )

C:> ipy pyc.py /target:exe /main:Varargs2.py Varargs2.py
 
 
Input Files:
Varargs2.py
Output:
Varargs2
Target:
ConsoleApplication
Platform:
ILOnly
Machine:
I386
Compiling...
Traceback (most recent call last):
 
File "c:/Program Files (x86)/IronPython 2.7/Tools/Scripts/pyc.py", line 159, in <module>
 
File "c:/Program Files (x86)/IronPython 2.7/Tools/Scripts/pyc.py", line 151, in Main
 
SystemError: Unable to make a reference to a transient module from a non-transient module.

file attachments

Closed Jun 19, 2011 at 5:24 AM by jdhardy
Fixed in 2.7.1 beta 1.

comments

hfoffani wrote Oct 1, 2010 at 3:35 PM

I think that in the standard lib there are some modules that fall in this case: cookielib.py (may be due to *CookieJar.py dependancies), modulefinder.py and zipfile.py. At least this same exception was thrown when I compiled all the stdlib modules.

kayub wrote Mar 21, 2011 at 6:56 AM

Pygments used to work in the older IronPython when compiling; now it fails miserably with this error. Thanks a lot :(

jhoward wrote Apr 1, 2011 at 11:25 PM

This is a problem with any function call with more than 13 arguments. Ultimately, it appears there is a problem with the generated System.Linq.Expressions.LambdaExpression that's being created and compiled internally. (See attached file)

jdhardy wrote Apr 9, 2011 at 7:22 PM

Fixed in b562628.