Commits

Nathan Taylor committed 2f5063c

changed assertion to ValueError

  • Participants
  • Parent commits 0ac3eb2
  • Branches improved_ebnfparse_error

Comments (0)

Files changed (2)

File pypy/rlib/parsing/ebnfparse.py

                     real_expansions.append(expansion)
                     real_changes.append(change)
                     continue
-                assert n != len(expansion), (
-                    "Rule %r's expansion needs at least one "
-                    "symbol with >0 repetitions" % rule.nonterminal)
+                if n == len(expansion):
+                    raise ValueError("Rule %r's expansion needs "
+                        "at least one symbol with >0 repetitions"
+                        % rule.nonterminal)
                 slices = []
                 start = 0
                 for i, (maybe, symbol) in enumerate(

File pypy/rlib/parsing/test/test_ebnfparse.py

 IGNORE: " ";
 foo: "A"?;
 """
-    excinfo = py.test.raises(AssertionError, parse_ebnf, grammar)
-    assert "Rule 'foo'" in str(excinfo.value)
+    excinfo = py.test.raises(ValueError, parse_ebnf, grammar)
+    assert "foo" in str(excinfo.value)