Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execfile unable to take arguments beyond 255! #45977

Closed
jgatkinsn mannequin opened this issue Dec 16, 2007 · 7 comments
Closed

Execfile unable to take arguments beyond 255! #45977

jgatkinsn mannequin opened this issue Dec 16, 2007 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@jgatkinsn
Copy link
Mannequin

jgatkinsn mannequin commented Dec 16, 2007

BPO 1636
Nosy @gvanrossum, @loewis
Files
  • builder.py
  • test.py: test reproducing the issue
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-04-27.22:56:11.308>
    created_at = <Date 2007-12-16.01:19:19.022>
    labels = ['interpreter-core', 'type-feature']
    title = 'Execfile unable to take arguments beyond 255!'
    updated_at = <Date 2010-04-27.22:56:11.306>
    user = 'https://bugs.python.org/jgatkinsn'

    bugs.python.org fields:

    activity = <Date 2010-04-27.22:56:11.306>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-04-27.22:56:11.308>
    closer = 'loewis'
    components = ['Interpreter Core']
    creation = <Date 2007-12-16.01:19:19.022>
    creator = 'jgatkinsn'
    dependencies = []
    files = ['8968', '17113']
    hgrepos = []
    issue_num = 1636
    keywords = []
    message_count = 7.0
    messages = ['58668', '58671', '58682', '58760', '58774', '104377', '104380']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'loewis', 'jgatkinsn', 'Alexander.Belopolsky']
    pr_nums = []
    priority = 'low'
    resolution = 'wont fix'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1636'
    versions = ['Python 2.5']

    @jgatkinsn
    Copy link
    Mannequin Author

    jgatkinsn mannequin commented Dec 16, 2007

    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.

    @jgatkinsn jgatkinsn mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Dec 16, 2007
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Dec 16, 2007

    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.

    @jgatkinsn
    Copy link
    Mannequin Author

    jgatkinsn mannequin commented Dec 17, 2007

    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\builder.py in
    loadModules(self, *mod
    Names)
    80 del self.__modPathsSeen[modPath]
    81 raise error.SmiError(
    ---> 82 'MIB module \"%s\" load error: %s' %
    (modPath, why)
    83 )
    84

    <class 'pysnmp.smi.error.SmiError'>: MIB module
    "c:\python25\lib\site-packages\p
    ysnmp\v4\smi\mibs\ADTRAN-TC.py" load error: more than 255 arguments
    (ADTRAN-TC.p
    y, line 33)

    Here's the code that loads it:
    try:
    execfile(modPath, g)
    except StandardError,
    why: del self.__modPathsSeen[modPath]
    raise error.SmiError( 'MIB module \"%s\" load error: %s' % (modPath, why) )

    @gvanrossum
    Copy link
    Member

    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.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Dec 18, 2007

    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.

    @AlexanderBelopolsky
    Copy link
    Mannequin

    AlexanderBelopolsky mannequin commented Apr 27, 2010

    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

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Apr 27, 2010

    Closing it as "won't fix": nobody is really interested in working on the problem.

    @loewis loewis mannequin closed this as completed Apr 27, 2010
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant