mcfletch / simpleparse

SimpleParse parser generator using mxTextTools (launchpad mirror)
Other
10 stars 12 forks source link

Python2 still supported? #9

Closed hernot closed 4 years ago

hernot commented 4 years ago

I do have a quick question. I'm contributing to ahds (https://github.com/emdb-empiar/ahds) package which uses SimpleParse to parse file headers containing structural information about content. This package first implemented for python2, is currently setup to still support python2. As i do get deep down in SimpleParse following UnicodeDecodeErrors emitted by ''.join(), when running on python2 my question is, do current versions of SimpleParse still support? In case not from which version on python2 support was dismissed? Would help us to decide whether to still try to keep python2 support or dismiss it for ahds package too as SimpleParse is required at its core.

Thank you very much in advance Hernot

  # remaining lines cut amira_header_grammar is multiline string prefixed by r
  #i have tested with str.decode, str encode but nothing changed same error or better
  # if using str.decode i get instead of decoding error an exception that signed char has negative value
  File "ahds/grammar.py", line 562, in parse_header
    parser = Parser(amira_header_grammar)
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/parser.py", line 37, in __init__
    definitionSources = definitionSources,
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 478, in __init__
    success, tags, next = self.parse( ebnf, self._rootProduction, processor=processor )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/baseparser.py", line 32, in parse
    return processor( value, data )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 32, in __call__
    result = dispatchList( self, tags, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return list(map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist)))
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 521, in declaration
    content = dispatch( self, sublist[1], buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 566, in seq_group
    children = dispatchList( self, sublist, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 59, in dispatchList
    return list(map( dispatch, [source]*len(taglist), taglist, [buffer]*len(taglist)))
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 541, in element_token
    result = dispatch( self, tup, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/dispatchprocessor.py", line 54, in dispatch
    return function( tag, buffer )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 619, in range
    value = ''.join(dispatchList( self, sublist, buffer)),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)

In case i do a

from __future__ import unicode_literals

I do get the following error

  File "ahds/grammar.py", line 562, in parse_header
    parser = Parser(amira_header_grammar)
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/parser.py", line 37, in __init__
    definitionSources = definitionSources,
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/simpleparsegrammar.py", line 478, in __init__
    success, tags, next = self.parse( ebnf, self._rootProduction, processor=processor )
  File "/usr/local/lib/python2.7/dist-packages/simpleparse/baseparser.py", line 30, in parse
    value = tag( data, self.buildTagger( production, processor), start, stop )
SystemError: Search-object search returned value < 0 (-1): probable bug in text processing engine
hernot commented 4 years ago

OK seems that simpleparse 2.1.1 is the last which supports python 2. Thanks you very much