[pypy-commit] pypy fix-tpname: fix _ast behavior

bdkearns noreply at buildbot.pypy.org
Fri May 2 05:48:57 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: fix-tpname
Changeset: r71179:4d193ee033eb
Date: 2014-05-01 22:02 -0400
http://bitbucket.org/pypy/pypy/changeset/4d193ee033eb/

Log:	fix _ast behavior

diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -121,10 +121,9 @@
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)
 
-AST.typedef = typedef.TypeDef("AST",
+AST.typedef = typedef.TypeDef("_ast.AST",
     _fields=_FieldsWrapper([]),
     _attributes=_FieldsWrapper([]),
-    __module__='_ast',
     __reduce__=interp2app(AST.reduce_w),
     __setstate__=interp2app(AST.setstate_w),
     __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -669,10 +669,9 @@
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)
 
-AST.typedef = typedef.TypeDef("AST",
+AST.typedef = typedef.TypeDef("_ast.AST",
     _fields=_FieldsWrapper([]),
     _attributes=_FieldsWrapper([]),
-    __module__='_ast',
     __reduce__=interp2app(AST.reduce_w),
     __setstate__=interp2app(AST.setstate_w),
     __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
diff --git a/pypy/module/_ast/test/test_ast.py b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -20,9 +20,9 @@
         assert isinstance(ast.__version__, str)
 
     def test_flags(self):
-        skip("broken")
         from copy_reg import _HEAPTYPE
-        assert self.ast.Module.__flags__ & _HEAPTYPE
+        assert self.ast.AST.__flags__ & _HEAPTYPE == 0
+        assert self.ast.Module.__flags__ & _HEAPTYPE == _HEAPTYPE
 
     def test_build_ast(self):
         ast = self.ast
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -997,6 +997,7 @@
     w_self.weakrefable = w_self.instancetypedef.weakrefable
     w_self.w_doc = w_self.space.wrap(w_self.instancetypedef.doc)
     ensure_common_attributes(w_self)
+    w_self.flag_heaptype = '__module__' in w_self.instancetypedef.rawdict
 
 def ensure_common_attributes(w_self):
     ensure_static_new(w_self)


More information about the pypy-commit mailing list