[pypy-svn] r54692 - in pypy/branch/2.5-features/pypy/interpreter/pyparser: . test

bgola at codespeak.net bgola at codespeak.net
Tue May 13 00:16:32 CEST 2008


Author: bgola
Date: Tue May 13 00:16:32 2008
New Revision: 54692

Modified:
   pypy/branch/2.5-features/pypy/interpreter/pyparser/astbuilder.py
   pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py
Log:
supporting the class A(): pass 2.5 syntax

Modified: pypy/branch/2.5-features/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/pyparser/astbuilder.py	(original)
+++ pypy/branch/2.5-features/pypy/interpreter/pyparser/astbuilder.py	Tue May 13 00:16:32 2008
@@ -632,16 +632,19 @@
 
 
 def build_classdef(builder, nb):
-    """classdef: 'class' NAME ['(' testlist ')'] ':' suite"""
+    """classdef: 'class' NAME ['(' [testlist] ')'] ':' suite"""
     atoms = get_atoms(builder, nb)
     lineno = atoms[0].lineno
     l = len(atoms)
     classname_token = atoms[1]
     assert isinstance(classname_token, TokenObject)
     classname = classname_token.get_value()
-    if l == 4:
+    if l == 4: # class NAME:
         basenames = []
         body = atoms[3]
+    elif l == 6: # class NAME():  # 2.5
+        basenames = []
+        body = atoms[5]
     else:
         assert l == 7
         basenames = []

Modified: pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py	(original)
+++ pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py	Tue May 13 00:16:32 2008
@@ -361,6 +361,9 @@
 
 one_stmt_classdefs = [
     "class Pdb(bdb.Bdb, cmd.Cmd): pass",
+    "class A(): pass",
+    "class A: pass",
+    "class A)(: x",
     ]
 
 docstrings = [



More information about the Pypy-commit mailing list