#39 preParse error in py3k version

closed-fixed
nobody
None
5
2010-06-25
2010-05-21
Anonymous
No

this assumes bug 3005531 to be fixed

executing "python3 testcase.py" (file attached) yields:

150725
Traceback (most recent call last):
File "testcase.py", line 11, in <module>
result = exp.parseFile("./pyparsing_py3.py")
File "/data/projekte/parsing/pyparsing/pyparsing_py3.py", line 1426, in parseFile
return self.parseString(file_contents, parseAll)
File "/data/projekte/parsing/pyparsing/pyparsing_py3.py", line 1068, in parseString
loc, tokens = self._parse( instring, 0 )
File "/data/projekte/parsing/pyparsing/pyparsing_py3.py", line 935, in _parseNoCache
preloc = self.preParse( instring, loc )
File "/data/projekte/parsing/pyparsing/pyparsing_py3.py", line 893, in preParse
while loc < instrlen and instring[loc] in wt:
TypeError: 'in <string>' requires string as left operand, not int

Discussion

  •  
    Attachments
  • Paul McGuire
    Paul McGuire
    2010-05-25

    It is not clear to me why this error is occurring now. Doesn't instring[loc] still return a string?

     
  • Actually not - I just added the following lines before line 893:

    print(loc)
    print(type(loc))
    print(type(instring))

    The last call before the error tells me that instring is of type 'bytes' .... something with py3k string handling and explicit difference between strings and bytes?

     
  • Paul McGuire
    Paul McGuire
    2010-06-23

    Bug is fixed in 1.5.3 - parseFile erroneously opens the input file using mode "rb", so input is read as bytes. Changed to use "rt".

     
  • Paul McGuire
    Paul McGuire
    2010-06-24

    • status: open --> open-fixed
     
  • Paul McGuire
    Paul McGuire
    2010-06-25

    • status: open-fixed --> closed-fixed