This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Execfile unable to take arguments beyond 255!
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 2.5
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Alexander.Belopolsky, gvanrossum, jgatkinsn, loewis
Priority: low Keywords:

Created on 2007-12-16 01:19 by jgatkinsn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit jgatkinsn, 2007-12-17 02:28 Alexander.Belopolsky, 2010-04-27 22:48 test reproducing the issue
Messages (7)
msg58668 - (view) Author: Jack Atkinson (jgatkinsn) Date: 2007-12-16 01:19
I found this problem while using PySNMP and trying to load a custom MIB
converted to python code.  Inside the PySNMP, it uses execfile() to load
the python MIBs, and I assume so it won't be put into a separate
namespace.  On one particular MIB, which I cannot modify because it's a
company product MIB, this error of unable to take in more than 255
arguments occurs.  The problem line is quite long, but surely in this
day and age of 32 bit to 64 bit machines this 255 constraint could be
done away with in the execfile function.  I'm assuming the 255
constraint has something to do with unsigned 8 bit number.
msg58671 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-12-16 10:45
Can you please be more specific? What code exactly are you executing,
and what is the exact error message that you get?

In the entire Python source code, the error message "Execfile unable to
take arguments beyond 255!" is never produced. Very few error messages
in Python include an exclamation mark at all.
msg58682 - (view) Author: Jack Atkinson (jgatkinsn) Date: 2007-12-17 02:28
Error message from ipython console:
In [28]: mibBuilder2 = builder.MibBuilder().loadModules('ADTRAN-TC')
<class 'pysnmp.smi.error.SmiError'>       Traceback (most recent call last)

C:\Documents and Settings\Jack Atkinson\<ipython console> in <module>()

c:\python25\lib\site-packages\pysnmp\v4\smi\ in
loadModules(self, *mod
     80                     del self.__modPathsSeen[modPath]
     81                     raise error.SmiError(
---> 82                         'MIB module \"%s\" load error: %s' %
(modPath, why)
     83                         )

<class 'pysnmp.smi.error.SmiError'>: MIB module
ysnmp\v4\smi\mibs\" load error: more than 255 arguments
y, line 33)

Here's the code that loads it:
execfile(modPath, g)
except StandardError,
why: del self.__modPathsSeen[modPath]
raise error.SmiError( 'MIB module \"%s\" load error: %s' % (modPath, why) )
msg58760 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-18 20:01
This comes from line 1845 in ast.c.

It has nothing to do with execfile(), it's just a constraint on the
generated bytecode.

Fixing this would be quite complex, and referring to "this day and age"
isn't going to raise its priority.  However, I'd be happy to accept a
patch that does away with this limit or at least raises it considerably.
msg58774 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-12-18 21:29
While you can't modify the MIB, I'm sure it would be possible to change
the generator code that compiles the MIB into Python source code, to
work around the restrictions in the byte code.
msg104377 - (view) Author: Alexander Belopolsky (Alexander.Belopolsky) Date: 2010-04-27 22:48
I don't have much to contribute other than a simple test to reproduce the issue:

>>> code = """                                                                                                                                                                                  
... def f(%s):                                                                                                                                                                                  
...   pass                                                                                                                                                                                      
... """ % ','.join('a%d' % i for i in range(300))
>>> exec(code)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2
SyntaxError: more than 255 arguments
msg104380 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-04-27 22:56
Closing it as "won't fix": nobody is really interested in working on the problem.
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 45977
2010-04-27 22:56:11loewissetstatus: open -> closed
resolution: wont fix
messages: + msg104380
2010-04-27 22:48:05Alexander.Belopolskysetfiles: +
nosy: + Alexander.Belopolsky
messages: + msg104377

2007-12-18 21:29:08loewissetmessages: + msg58774
2007-12-18 20:01:36gvanrossumsetpriority: low
nosy: + gvanrossum
messages: + msg58760
2007-12-17 02:28:31jgatkinsnsetfiles: +
messages: + msg58682
2007-12-16 10:45:58loewissetnosy: + loewis
messages: + msg58671
2007-12-16 01:19:19jgatkinsncreate