Hello community, here is the log from the commit of package python-pyparsing for openSUSE:Factory checked in at 2019-11-22 10:25:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pyparsing (Old) and /work/SRC/openSUSE:Factory/.python-pyparsing.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyparsing" Fri Nov 22 10:25:08 2019 rev:35 rq:749105 version:2.4.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pyparsing/python-pyparsing.changes 2019-11-04 17:11:03.556559375 +0100 +++ /work/SRC/openSUSE:Factory/.python-pyparsing.new.26869/python-pyparsing.changes 2019-11-22 10:25:14.541276767 +0100 @@ -1,0 +2,28 @@ +Sat Nov 16 16:46:50 UTC 2019 - Arun Persaud <a...@gmx.de> + +- update to version 2.4.5: + * Fixed encoding when setup.py reads README.rst to include the + project long description when uploading to PyPI. A stray unicode + space in README.rst prevented the source install on systems whose + default encoding is not 'utf-8'. + +- changes from version 2.4.4: + * Unresolved symbol reference in 2.4.3 release was masked by stdout + buffering in unit tests, thanks for the prompt heads-up, Ned + Batchelder! + +- changes from version 2.4.3: + * Fixed a bug in ParserElement.__eq__ that would for some parsers + create a recursion error at parser definition time. Thanks to + Michael Clerx for the assist. (Addresses issue #123) + * Fixed bug in indentedBlock where a block that ended at the end of + the input string could cause pyaprsing to loop forever. Raised as + part of discussion on StackOverflow with geckos. + * Backports from pyparsing 3.0.0: + + __diag__.enable_all_warnings() + + Fixed bug in PrecededBy which caused infinite recursion, issue + #127 + + support for using regex-compiled RE to construct Regex + expressions + +------------------------------------------------------------------- Old: ---- pyparsing-2.4.2.tar.gz New: ---- pyparsing-2.4.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pyparsing.spec ++++++ --- /var/tmp/diff_new_pack.hnh7zg/_old 2019-11-22 10:25:15.669276434 +0100 +++ /var/tmp/diff_new_pack.hnh7zg/_new 2019-11-22 10:25:15.677276431 +0100 @@ -28,7 +28,7 @@ %bcond_with test %endif Name: python-pyparsing%{psuffix} -Version: 2.4.2 +Version: 2.4.5 Release: 0 Summary: Grammar Parser Library for Python License: MIT AND GPL-2.0-or-later AND GPL-3.0-or-later ++++++ pyparsing-2.4.2.tar.gz -> pyparsing-2.4.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/CHANGES new/pyparsing-2.4.5/CHANGES --- old/pyparsing-2.4.2/CHANGES 2019-07-29 05:55:06.000000000 +0200 +++ new/pyparsing-2.4.5/CHANGES 2019-11-10 00:01:34.000000000 +0100 @@ -2,6 +2,37 @@ Change Log ========== +Version 2.4.5 - November, 2019 +------------------------------ +- Fixed encoding when setup.py reads README.rst to include the + project long description when uploading to PyPI. A stray + unicode space in README.rst prevented the source install on + systems whose default encoding is not 'utf-8'. + + +Version 2.4.4 - November, 2019 +-------------------------------- +- Unresolved symbol reference in 2.4.3 release was masked by stdout + buffering in unit tests, thanks for the prompt heads-up, Ned + Batchelder! + + +Version 2.4.3 - November, 2019 +------------------------------ +- Fixed a bug in ParserElement.__eq__ that would for some parsers + create a recursion error at parser definition time. Thanks to + Michael Clerx for the assist. (Addresses issue #123) + +- Fixed bug in indentedBlock where a block that ended at the end + of the input string could cause pyaprsing to loop forever. Raised + as part of discussion on StackOverflow with geckos. + +- Backports from pyparsing 3.0.0: + . __diag__.enable_all_warnings() + . Fixed bug in PrecededBy which caused infinite recursion, issue #127 + . support for using regex-compiled RE to construct Regex expressions + + Version 2.4.2 - July, 2019 -------------------------- - Updated the shorthand notation that has been added for repetition diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/PKG-INFO new/pyparsing-2.4.5/PKG-INFO --- old/pyparsing-2.4.2/PKG-INFO 2019-07-30 03:31:43.000000000 +0200 +++ new/pyparsing-2.4.5/PKG-INFO 2019-11-10 00:07:22.000000000 +0100 @@ -1,13 +1,87 @@ Metadata-Version: 1.2 Name: pyparsing -Version: 2.4.2 +Version: 2.4.5 Summary: Python parsing module Home-page: https://github.com/pyparsing/pyparsing/ Author: Paul McGuire Author-email: pt...@users.sourceforge.net License: MIT License Download-URL: https://pypi.org/project/pyparsing/ -Description: UNKNOWN +Description: PyParsing -- A Python Parsing Module + ==================================== + + |Build Status| + + Introduction + ============ + + The pyparsing module is an alternative approach to creating and + executing simple grammars, vs. the traditional lex/yacc approach, or the + use of regular expressions. The pyparsing module provides a library of + classes that client code uses to construct the grammar directly in + Python code. + + *[Since first writing this description of pyparsing in late 2003, this + technique for developing parsers has become more widespread, under the + name Parsing Expression Grammars - PEGs. See more information on PEGs at* + https://en.wikipedia.org/wiki/Parsing_expression_grammar *.]* + + Here is a program to parse ``"Hello, World!"`` (or any greeting of the form + ``"salutation, addressee!"``): + + .. code:: python + + from pyparsing import Word, alphas + greet = Word(alphas) + "," + Word(alphas) + "!" + hello = "Hello, World!" + print(hello, "->", greet.parseString(hello)) + + The program outputs the following:: + + Hello, World! -> ['Hello', ',', 'World', '!'] + + The Python representation of the grammar is quite readable, owing to the + self-explanatory class names, and the use of '+', '|' and '^' operator + definitions. + + The parsed results returned from ``parseString()`` can be accessed as a + nested list, a dictionary, or an object with named attributes. + + The pyparsing module handles some of the problems that are typically + vexing when writing text parsers: + + - extra or missing whitespace (the above program will also handle ``"Hello,World!"``, ``"Hello , World !"``, etc.) + - quoted strings + - embedded comments + + The examples directory includes a simple SQL parser, simple CORBA IDL + parser, a config file parser, a chemical formula parser, and a four- + function algebraic notation parser, among many others. + + Documentation + ============= + + There are many examples in the online docstrings of the classes + and methods in pyparsing. You can find them compiled into online docs + at https://pyparsing-docs.readthedocs.io/en/latest/. Additional + documentation resources and project info are listed in the online + GitHub wiki, at https://github.com/pyparsing/pyparsing/wiki. An + entire directory of examples is at + https://github.com/pyparsing/pyparsing/tree/master/examples. + + License + ======= + + MIT License. See header of pyparsing.py + + History + ======= + + See CHANGES file. + + .. |Build Status| image:: https://travis-ci.org/pyparsing/pyparsing.svg?branch=master + :target: https://travis-ci.org/pyparsing/pyparsing + Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -24,4 +98,5 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/README.rst new/pyparsing-2.4.5/README.rst --- old/pyparsing-2.4.2/README.rst 2019-07-30 03:30:53.000000000 +0200 +++ new/pyparsing-2.4.5/README.rst 2019-11-10 00:01:34.000000000 +0100 @@ -7,7 +7,7 @@ ============ The pyparsing module is an alternative approach to creating and -executing simple grammars, vs. the traditional lex/yacc approach, or the +executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/docs/HowToUsePyparsing.rst new/pyparsing-2.4.5/docs/HowToUsePyparsing.rst --- old/pyparsing-2.4.2/docs/HowToUsePyparsing.rst 2019-07-29 05:55:06.000000000 +0200 +++ new/pyparsing-2.4.5/docs/HowToUsePyparsing.rst 2019-11-03 22:47:38.000000000 +0100 @@ -821,7 +821,7 @@ If an expression is not provided for the content argument, the nested expression will capture all whitespace-delimited content between delimiters -vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv as a list of separate values. + as a list of separate values. Use the ignoreExpr argument to define expressions that may contain opening or closing characters that should not be treated as opening @@ -900,14 +900,14 @@ - ``replaceWith(replString)`` - returns a parse action that simply returns the replString; useful when using transformString, or converting HTML entities, as in:: - nbsp = Literal(" ").setParseAction(replaceWith("<BLANK>")) + nbsp = Literal(" ").setParseAction( replaceWith("<BLANK>") ) - ``keepOriginalText``- (deprecated, use originalTextFor_ instead) restores any internal whitespace or suppressed text within the tokens for a matched parse expression. This is especially useful when defining expressions for scanString or transformString applications. -- ``withAttribute(*args, **kwargs)`` - helper to create a validating parse action to be used with start tags created +- ``withAttribute( *args, **kwargs )`` - helper to create a validating parse action to be used with start tags created with ``makeXMLTags`` or ``makeHTMLTags``. Use ``withAttribute`` to qualify a starting tag with a required attribute value, to avoid false matches on common tags such as ``<TD>`` or ``<DIV>``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/pyparsing.egg-info/PKG-INFO new/pyparsing-2.4.5/pyparsing.egg-info/PKG-INFO --- old/pyparsing-2.4.2/pyparsing.egg-info/PKG-INFO 2019-07-30 03:31:42.000000000 +0200 +++ new/pyparsing-2.4.5/pyparsing.egg-info/PKG-INFO 2019-11-10 00:07:21.000000000 +0100 @@ -1,13 +1,87 @@ Metadata-Version: 1.2 Name: pyparsing -Version: 2.4.2 +Version: 2.4.5 Summary: Python parsing module Home-page: https://github.com/pyparsing/pyparsing/ Author: Paul McGuire Author-email: pt...@users.sourceforge.net License: MIT License Download-URL: https://pypi.org/project/pyparsing/ -Description: UNKNOWN +Description: PyParsing -- A Python Parsing Module + ==================================== + + |Build Status| + + Introduction + ============ + + The pyparsing module is an alternative approach to creating and + executing simple grammars, vs. the traditional lex/yacc approach, or the + use of regular expressions. The pyparsing module provides a library of + classes that client code uses to construct the grammar directly in + Python code. + + *[Since first writing this description of pyparsing in late 2003, this + technique for developing parsers has become more widespread, under the + name Parsing Expression Grammars - PEGs. See more information on PEGs at* + https://en.wikipedia.org/wiki/Parsing_expression_grammar *.]* + + Here is a program to parse ``"Hello, World!"`` (or any greeting of the form + ``"salutation, addressee!"``): + + .. code:: python + + from pyparsing import Word, alphas + greet = Word(alphas) + "," + Word(alphas) + "!" + hello = "Hello, World!" + print(hello, "->", greet.parseString(hello)) + + The program outputs the following:: + + Hello, World! -> ['Hello', ',', 'World', '!'] + + The Python representation of the grammar is quite readable, owing to the + self-explanatory class names, and the use of '+', '|' and '^' operator + definitions. + + The parsed results returned from ``parseString()`` can be accessed as a + nested list, a dictionary, or an object with named attributes. + + The pyparsing module handles some of the problems that are typically + vexing when writing text parsers: + + - extra or missing whitespace (the above program will also handle ``"Hello,World!"``, ``"Hello , World !"``, etc.) + - quoted strings + - embedded comments + + The examples directory includes a simple SQL parser, simple CORBA IDL + parser, a config file parser, a chemical formula parser, and a four- + function algebraic notation parser, among many others. + + Documentation + ============= + + There are many examples in the online docstrings of the classes + and methods in pyparsing. You can find them compiled into online docs + at https://pyparsing-docs.readthedocs.io/en/latest/. Additional + documentation resources and project info are listed in the online + GitHub wiki, at https://github.com/pyparsing/pyparsing/wiki. An + entire directory of examples is at + https://github.com/pyparsing/pyparsing/tree/master/examples. + + License + ======= + + MIT License. See header of pyparsing.py + + History + ======= + + See CHANGES file. + + .. |Build Status| image:: https://travis-ci.org/pyparsing/pyparsing.svg?branch=master + :target: https://travis-ci.org/pyparsing/pyparsing + Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers @@ -24,4 +98,5 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/pyparsing.egg-info/SOURCES.txt new/pyparsing-2.4.5/pyparsing.egg-info/SOURCES.txt --- old/pyparsing-2.4.2/pyparsing.egg-info/SOURCES.txt 2019-07-30 03:31:42.000000000 +0200 +++ new/pyparsing-2.4.5/pyparsing.egg-info/SOURCES.txt 2019-11-10 00:07:21.000000000 +0100 @@ -133,4 +133,6 @@ test/karthik.ini test/parsefiletest_input_file.txt test/__pycache__/__init__.cpython-35.pyc -test/__pycache__/jsonParserTests.cpython-35.pyc \ No newline at end of file +test/__pycache__/__init__.cpython-38.pyc +test/__pycache__/jsonParserTests.cpython-35.pyc +test/__pycache__/jsonParserTests.cpython-38.pyc \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/pyparsing.py new/pyparsing-2.4.5/pyparsing.py --- old/pyparsing-2.4.2/pyparsing.py 2019-07-29 05:55:06.000000000 +0200 +++ new/pyparsing-2.4.5/pyparsing.py 2019-11-10 00:06:58.000000000 +0100 @@ -95,8 +95,8 @@ namespace class """ -__version__ = "2.4.2" -__versionTime__ = "29 Jul 2019 02:58 UTC" +__version__ = "2.4.5" +__versionTime__ = "09 Nov 2019 23:03 UTC" __author__ = "Paul McGuire <pt...@users.sourceforge.net>" import string @@ -185,7 +185,13 @@ __diag__.warn_on_multiple_string_args_to_oneof = False __diag__.enable_debug_on_named_expressions = False -# ~ sys.stderr.write("testing pyparsing module, version %s, %s\n" % (__version__, __versionTime__)) +def _enable_all_warnings(): + __diag__.warn_multiple_tokens_in_named_alternation = True + __diag__.warn_ungrouped_named_tokens_in_collection = True + __diag__.warn_name_set_on_empty_Forward = True + __diag__.warn_on_multiple_string_args_to_oneof = True +__diag__.enable_all_warnings = _enable_all_warnings + __all__ = ['__version__', '__versionTime__', '__author__', '__compat__', '__diag__', 'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty', @@ -206,7 +212,7 @@ 'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute', 'indentedBlock', 'originalTextFor', 'ungroup', 'infixNotation', 'locatedExpr', 'withClass', 'CloseMatch', 'tokenMap', 'pyparsing_common', 'pyparsing_unicode', 'unicode_set', - 'conditionAsParseAction', + 'conditionAsParseAction', 're', ] system_version = tuple(sys.version_info)[:3] @@ -2561,15 +2567,13 @@ raise exc def __eq__(self, other): - if isinstance(other, ParserElement): - if PY_3: - self is other or super(ParserElement, self).__eq__(other) - else: - return self is other or vars(self) == vars(other) + if self is other: + return True elif isinstance(other, basestring): return self.matches(other) - else: - return super(ParserElement, self) == other + elif isinstance(other, ParserElement): + return vars(self) == vars(other) + return False def __ne__(self, other): return not (self == other) @@ -3252,14 +3256,23 @@ If the given regex contains named groups (defined using ``(?P<name>...)``), these will be preserved as named parse results. + If instead of the Python stdlib re module you wish to use a different RE module + (such as the `regex` module), you can replace it by either building your + Regex object with a compiled RE that was compiled using regex: + Example:: realnum = Regex(r"[+-]?\d+\.\d*") date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)') # ref: https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression roman = Regex(r"M{0,4}(CM|CD|D?{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})") + + # use regex module instead of stdlib re module to construct a Regex using + # a compiled regular expression + import regex + parser = pp.Regex(regex.compile(r'[0-9]')) + """ - compiledREtype = type(re.compile("[A-Z]")) def __init__(self, pattern, flags=0, asGroupList=False, asMatch=False): """The parameters ``pattern`` and ``flags`` are passed to the ``re.compile()`` function as-is. See the Python @@ -3284,13 +3297,13 @@ SyntaxWarning, stacklevel=2) raise - elif isinstance(pattern, Regex.compiledREtype): + elif hasattr(pattern, 'pattern') and hasattr(pattern, 'match'): self.re = pattern - self.pattern = self.reString = str(pattern) + self.pattern = self.reString = pattern.pattern self.flags = flags else: - raise ValueError("Regex may only be constructed with a string or a compiled RE object") + raise TypeError("Regex may only be constructed with a string or a compiled RE object") self.re_match = self.re.match @@ -4566,6 +4579,7 @@ self.retreat = retreat self.errmsg = "not preceded by " + str(expr) self.skipWhitespace = False + self.parseAction.append(lambda s, l, t: t.__delitem__(slice(None, None))) def parseImpl(self, instring, loc=0, doActions=True): if self.exact: @@ -4576,19 +4590,18 @@ else: # retreat specified a maximum lookbehind window, iterate test_expr = self.expr + StringEnd() - instring_slice = instring[:loc] + instring_slice = instring[max(0, loc - self.retreat):loc] last_expr = ParseException(instring, loc, self.errmsg) - for offset in range(1, min(loc, self.retreat + 1)): + for offset in range(1, min(loc, self.retreat + 1)+1): try: - _, ret = test_expr._parse(instring_slice, loc - offset) + # print('trying', offset, instring_slice, repr(instring_slice[loc - offset:])) + _, ret = test_expr._parse(instring_slice, len(instring_slice) - offset) except ParseBaseException as pbe: last_expr = pbe else: break else: raise last_expr - # return empty list of tokens, but preserve any defined results names - del ret[:] return loc, ret @@ -6305,18 +6318,18 @@ if curCol < indentStack[-1]: indentStack.pop() - NL = OneOrMore(LineEnd().setWhitespaceChars("\t ").suppress()) + NL = OneOrMore(LineEnd().setWhitespaceChars("\t ").suppress(), stopOn=StringEnd()) INDENT = (Empty() + Empty().setParseAction(checkSubIndent)).setName('INDENT') PEER = Empty().setParseAction(checkPeerIndent).setName('') UNDENT = Empty().setParseAction(checkUnindent).setName('UNINDENT') if indent: smExpr = Group(Optional(NL) + INDENT - + OneOrMore(PEER + Group(blockStatementExpr) + Optional(NL)) + + OneOrMore(PEER + Group(blockStatementExpr) + Optional(NL), stopOn=StringEnd()) + UNDENT) else: smExpr = Group(Optional(NL) - + OneOrMore(PEER + Group(blockStatementExpr) + Optional(NL)) + + OneOrMore(PEER + Group(blockStatementExpr) + Optional(NL), stopOn=StringEnd()) + UNDENT) smExpr.setFailAction(lambda a, b, c, d: reset_stack()) blockStatementExpr.ignore(_bslash + LineEnd()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/setup.py new/pyparsing-2.4.5/setup.py --- old/pyparsing-2.4.2/setup.py 2019-04-08 05:31:29.000000000 +0200 +++ new/pyparsing-2.4.5/setup.py 2019-11-10 00:01:34.000000000 +0100 @@ -4,6 +4,14 @@ from setuptools import setup from pyparsing import __version__ as pyparsing_version +from io import open + +# The directory containing this file +README_name = __file__.replace("setup.py", "README.rst") + +# The text of the README file +with open(README_name, encoding='utf8') as README: + pyparsing_main_doc = README.read() modules = ["pyparsing",] @@ -11,6 +19,7 @@ name = "pyparsing", version = pyparsing_version, description = "Python parsing module", + long_description = pyparsing_main_doc, author = "Paul McGuire", author_email = "pt...@users.sourceforge.net", url = "https://github.com/pyparsing/pyparsing/", @@ -35,5 +44,6 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', ] ) Binary files old/pyparsing-2.4.2/test/__init__.pyc and new/pyparsing-2.4.5/test/__init__.pyc differ Binary files old/pyparsing-2.4.2/test/__pycache__/__init__.cpython-35.pyc and new/pyparsing-2.4.5/test/__pycache__/__init__.cpython-35.pyc differ Binary files old/pyparsing-2.4.2/test/__pycache__/__init__.cpython-38.pyc and new/pyparsing-2.4.5/test/__pycache__/__init__.cpython-38.pyc differ Binary files old/pyparsing-2.4.2/test/__pycache__/jsonParserTests.cpython-35.pyc and new/pyparsing-2.4.5/test/__pycache__/jsonParserTests.cpython-35.pyc differ Binary files old/pyparsing-2.4.2/test/__pycache__/jsonParserTests.cpython-38.pyc and new/pyparsing-2.4.5/test/__pycache__/jsonParserTests.cpython-38.pyc differ Binary files old/pyparsing-2.4.2/test/jsonParserTests.pyc and new/pyparsing-2.4.5/test/jsonParserTests.pyc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparsing-2.4.2/unitTests.py new/pyparsing-2.4.5/unitTests.py --- old/pyparsing-2.4.2/unitTests.py 2019-07-25 05:08:36.000000000 +0200 +++ new/pyparsing-2.4.5/unitTests.py 2019-11-05 21:55:02.000000000 +0100 @@ -85,6 +85,8 @@ class ParseTestCase(TestCase): def __init__(self): super(ParseTestCase, self).__init__(methodName='_runTest') + self.expect_traceback = False + self.expect_warning = False def _runTest(self): @@ -103,6 +105,12 @@ print_("<<<< End of test",str(self)) print_() + output = buffered_stdout.getvalue() + if "Traceback" in output and not self.expect_traceback: + raise Exception("traceback in stdout") + if "Warning" in output and not self.expect_warning: + raise Exception("warning in stdout") + except Exception as exc: if BUFFER_OUTPUT: print_() @@ -1247,6 +1255,8 @@ class CustomQuotesTest(ParseTestCase): def runTest(self): + self.expect_warning = True + from pyparsing import QuotedString testString = r""" @@ -1861,6 +1871,7 @@ class ParseUsingRegex(ParseTestCase): def runTest(self): + self.expect_warning = True import re @@ -1963,6 +1974,7 @@ class RegexSubTest(ParseTestCase): def runTest(self): + self.expect_warning = True import pyparsing as pp print_("test sub with string") @@ -2046,6 +2058,21 @@ "Erroneous named results for {0}: expected {1}, got {2}".format(expr, expected_dict, result.asDict())) + # infinite loop test - from Issue #127 + string_test = 'notworking' + # negs = pp.Or(['not', 'un'])('negs') + negs_pb = pp.PrecededBy('not', retreat=100)('negs_lb') + # negs_pb = pp.PrecededBy(negs, retreat=100)('negs_lb') + pattern = pp.Group(negs_pb + pp.Literal('working'))('main') + + results = pattern.searchString(string_test) + try: + print_(results.dump()) + except RecursionError: + self.assertTrue(False, "got maximum excursion limit exception") + else: + self.assertTrue(True, "got maximum excursion limit exception") + class CountedArrayTest(ParseTestCase): def runTest(self): @@ -3868,8 +3895,8 @@ for r, exp in zip(results, expected): if exp is not None: - self.assertEquals(r[1].mismatches, exp, - "fail CloseMatch between %r and %r" % (searchseq.match_string, r[0])) + self.assertEqual(r[1].mismatches, exp, + "fail CloseMatch between %r and %r" % (searchseq.match_string, r[0])) print_(r[0], 'exc: %s' % r[1] if exp is None and isinstance(r[1], Exception) else ("no match", "match")[r[1].mismatches == exp]) @@ -3948,6 +3975,8 @@ class ParseActionExceptionTest(ParseTestCase): def runTest(self): + self.expect_traceback = True + import pyparsing as pp import traceback @@ -4405,6 +4434,7 @@ with self.assertWarns(UserWarning, msg="failed to warn of And within alternation"): expr = (expr_a | expr_b)('rexp') else: + self.expect_warning = True expr = (expr_a | expr_b)('rexp') expr.runTests(""" not the bird @@ -4445,6 +4475,7 @@ with self.assertWarns(UserWarning, msg="failed to warn of And within alternation"): expr = (expr_a ^ expr_b)('rexp') else: + self.expect_warning = True expr = (expr_a ^ expr_b)('rexp') expr.runTests("""\ not the bird @@ -4599,6 +4630,8 @@ " ungrouped named expressions"): path = coord[...].setResultsName('path') + pp.__diag__.warn_ungrouped_named_tokens_in_collection = False + class WarnNameSetOnEmptyForwardTest(ParseTestCase): """ @@ -4664,10 +4697,10 @@ """) output = test_stdout.getvalue() print_(output) - self.assertEquals(output, - expected_debug_output, - "failed to auto-enable debug on named expressions " - "using enable_debug_on_named_expressions") + self.assertEqual(output, + expected_debug_output, + "failed to auto-enable debug on named expressions " + "using enable_debug_on_named_expressions") class UndesirableButCommonPracticesTest(ParseTestCase): @@ -4700,6 +4733,7 @@ class MiscellaneousParserTests(ParseTestCase): def runTest(self): + self.expect_warning = True runtests = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" if IRON_PYTHON_ENV: @@ -4958,4 +4992,5 @@ BUFFER_OUTPUT = False result = testRunner.run(makeTestSuiteTemp(testclasses)) + sys.stdout.flush() exit(0 if result.wasSuccessful() else 1)