[Pyparsing] Possible bug with And._ErrorStop
Brought to you by:
ptmcg
From: Johannes M. <Joh...@ne...> - 2012-09-20 13:01:31
|
Hey there. I am currently working on adding proper error handling to my parser and ran into a problem with the ErrorStop functionality of the And-class. This works: CaselessKeyword("foo") + "bar" But using ErrorStop raises an AttributeError: CaselessKeyword("foo") - "bar" Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 1384, in __repr__ return _ustr(self) File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 122, in _ustr return str(obj) File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 2394, in __str__ File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 122, in _ustr return str(obj) File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 1381, in __str__ return self.name File "/usr/local/lib/python2.7/dist-packages/pyparsing.py", line 1424, in __getattr__ raise AttributeError("no such attribute " + aname) AttributeError: no such attribute name This is because when "And.__sub__" initialises the "_ErrorStop" object "_ErrorStop.__init__" calls: super(Empty, self).__init__(*args, **kwargs) instead of: super(_ErrorStop, self).__init__(*args, **kwargs) So the constructor of "Empty", which is setting "name", will be skipped. I suppose that is not intended? Best regards, -- Johannes Meyer Junior Application Developer NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nürnberg Tel: +49 911 92885-0 | Fax: +49 911 92885-77 GF: Julian Hein, Bernd Erk | AG Nürnberg HRB18461 | http://www.netways.de<http://www.netways.de/> | joh...@ne...<mailto:joh...@ne...> ** NETWAYS Open Source Monitoring Conference 2012 | Nürnberg, 17. und 18. Oktober 2012 | http://www.netways.de/osmc ** ** Puppet Camp 2012 | Nürnberg, 19. Oktober 2012 | http://www.netways.de/puppetcamp ** |