#5 __doinit__ error

closed
nobody
None
5
2005-01-27
2005-01-27
Kerri Reno
No

I've got a program that I've created to parse a file
using pyparsing. It works fine on my XP, but when I
upload it to the unix box, I get this error:

AttributeError: 'ParseResults' object has no attribute
'_ParseResults__doinit'

any ideas? The whole thing is attached, if that's any
help...

Thanks in advance!
Kerri

Discussion

  • Kerri Reno
    Kerri Reno
    2005-01-27

     
    Attachments
  • Kerri Reno
    Kerri Reno
    2005-01-27

    Logged In: YES
    user_id=1206315

    it's got lots of prints, etc in it for debugging, so please
    don't critique my code :)

     
  • Paul McGuire
    Paul McGuire
    2005-01-27

    Logged In: YES
    user_id=893320

    Kerri -

    __doinit is a private internal variable of the ParseResults
    class. It is used to help optimize the *frequent* case where
    a ParseResults object is created from another ParseResults
    object.

    What versions of pyparsing and Python are you running? I
    have not yet tested pyparsing on Python 2.4, so this may be
    an issue. Which __doinit reference is Python complaining
    about, the one in __new__ or the one in __init__?

    -- Paul

     
  • Kerri Reno
    Kerri Reno
    2005-01-27

    Logged In: YES
    user_id=1206315

    Paul,

    Looks like it's in __new__, the entire traceback follows.
    I'm running python 2.3.5c1 and pyparsing 1.2.2 on my XP
    (where it works) and python 2.2.3 and pyparsing 1.2.2 on the
    unix box (where it doesn't work).

    Kerri

    Traceback (most recent call last):
    File "SourceTree.py", line 109, in ?
    execute(hdf,args,env)
    File "SourceTree.py", line 21, in execute
    GetStuff(url)
    File "SourceTree.py", line 87, in GetStuff
    if fp.FileParse(filehandle) == 0:
    File "SourceTree.py", line 60, in FileParse
    x = file.parseFile(input_file)
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    657, in parseFile
    return self.parseString(file_contents)
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    503, in parseString
    loc, tokens = self.parse( instring.expandtabs(), 0 )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    452, in parse
    loc,tokens = self.parseImpl( instring, loc, doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    1167, in parseImpl
    loc, resultlist = self.exprs[0].parse( instring, loc,
    doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    452, in parse
    loc,tokens = self.parseImpl( instring, loc, doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    1321, in parseImpl
    return self.expr.parse( instring, loc, doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    452, in parse
    loc,tokens = self.parseImpl( instring, loc, doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    1167, in parseImpl
    loc, resultlist = self.exprs[0].parse( instring, loc,
    doActions )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    460, in parse
    retTokens = ParseResults( tokens, self.resultsName,
    asList=self.saveList, modal=self.modalResults )
    File
    "/usr/local/lib/python2.2/site-packages/pyparsing.py", line
    119, in __new__
    retobj.__doinit = True
    AttributeError: 'ParseResults' object has no attribute
    '_ParseResults__doinit'

     
  • Kerri Reno
    Kerri Reno
    2005-01-27

    Logged In: YES
    user_id=1206315

    the system I uploaded to is running FreeBSD 4.9, if that
    makes any difference...

     
  • Paul McGuire
    Paul McGuire
    2005-01-27

    Logged In: YES
    user_id=893320

    pyparsing requires Python 2.3. Any chance you can upgrade
    your Unix machine?

    -- Paul

     
  • Paul McGuire
    Paul McGuire
    2005-01-27

    Logged In: YES
    user_id=893320

    pyparsing requires Python 2.3. Any chance you can upgrade
    your Unix machine?

    -- Paul

     
  • Kerri Reno
    Kerri Reno
    2005-01-27

    Logged In: YES
    user_id=1206315

    Paul --

    Sorry, I didn't realize that. There's a problem with
    upgrading, something about Zope. We'll try to run it on
    another box. Thanks for your help!

     
  • Paul McGuire
    Paul McGuire
    2005-01-27

    Logged In: YES
    user_id=893320

    Just a quick comment on your grammar. I notice you are
    using SkipTo to jump over chunks of code between the items
    that are meaningful to you. You might try using scanString
    instead of parseString for something like this. Here's
    something how it would look for your program:

    # opening comment
    line1 = CaselessLiteral('Proc') + restOfLine
    desc = Literal('!').suppress() + restOfLine
    desc = desc.setResultsName('desc')
    openingComment = line1 + desc

    # form name
    form = CaselessLiteral('reset form') + Word
    (alphas).setResultsName('form')

    # execute "CALL blah"
    execcall = (CaselessLiteral('execute "call').suppress() +
    ZeroOrMore(Word(alphas)) +
    Literal('"').suppress())

    matches = ( openingComment | form | execcall )

    filetext = file(input_file).read()

    for start,end,tokens in matches.scanString(filetext):
    print tokens.asList(), tokens.items()

    HTH,
    -- Paul

     
  • Paul McGuire
    Paul McGuire
    2005-01-27

    • status: open --> closed