msg55818 - (view) |
Author: David Binger (dbinger) |
Date: 2007-09-11 11:05 |
>>> parser.sequence2st(parser.suite("class A(object): pass").tolist()) Traceback (most recent call last): File "", line 1, in parser.ParserError: Expected node type 326, got 329. --- The Grammar in python 3 uses "arglist" instead of "testlist" for class definitions. The parsermodule's validate_class() calls validate_testlist() where it should now be calling validate_arglist(). |
|
|
msg57243 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2007-11-08 13:57 |
It's still breaking but Guido should know how to fix the parser. |
|
|
msg57288 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2007-11-09 00:24 |
No, I didn't write the parser module (which isn't the parser, just a wrapper to make it accessible from Python). |
|
|
msg57526 - (view) |
Author: David Binger (dbinger) |
Date: 2007-11-15 11:46 |
The one line patch below makes "import parser; parser.sequence2st(parser.suite("class A(object): pass").tolist())" work. It puts the parsermodule's validation back in sync with the Python3 grammar for this rule of the grammar. This bug is a serious problem for me. Index: Modules/parsermodule.c =================================================================== --- Modules/parsermodule.c (revision 58978) +++ Modules/parsermodule.c (working copy) @@ -992,7 +992,7 @@ if (res) { if (nch == 7) { res = ((validate_lparen(CHILD(tree, 2)) && - validate_testlist(CHILD(tree, 3)) && + validate_arglist(CHILD(tree, 3)) && validate_rparen(CHILD(tree, 4)))); } else if (nch == 6) { |
|
|
msg57539 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2007-11-15 17:29 |
Can you submit a unittest that catches this? Then I can check in the fix. |
|
|
msg57549 - (view) |
Author: David Binger (dbinger) |
Date: 2007-11-15 18:50 |
Okay, here is the whole thing with a unittest that exposes the problem. Index: Lib/test/test_parser.py =================================================================== --- Lib/test/test_parser.py (revision 58984) +++ Lib/test/test_parser.py (working copy) @@ -136,6 +136,7 @@ def test_class_defs(self): self.check_suite("class foo():pass") + self.check_suite("class foo(object):pass") def test_import_from_statement(self): self.check_suite("from sys.path import *") Index: Modules/parsermodule.c =================================================================== --- Modules/parsermodule.c (revision 58984) +++ Modules/parsermodule.c (working copy) @@ -992,7 +992,7 @@ if (res) { if (nch == 7) { res = ((validate_lparen(CHILD(tree, 2)) && - validate_testlist(CHILD(tree, 3)) && + validate_arglist(CHILD(tree, 3)) && validate_rparen(CHILD(tree, 4)))); } else if (nch == 6) { |
|
|
msg57550 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2007-11-15 19:17 |
Committed revision 58987. |
|
|