Commits

Alex Gaynor committed 893a3f8 Merge

merged upstream.

Comments (0)

Files changed (11)

lib-python/modified-2.7.0/ctypes/test/test_cast.py

 import unittest
 import sys
 
-from ctypes.test import xfail
-
 class Test(unittest.TestCase):
 
     def test_array2pointer(self):

lib-python/modified-2.7.0/ctypes/test/test_init.py

 from ctypes import *
 import unittest
-from ctypes.test import xfail
 
 class X(Structure):
     _fields_ = [("a", c_int),
 
 
 class InitTest(unittest.TestCase):
-    @xfail
     def test_get(self):
         # make sure the only accessing a nested structure
         # doesn't call the structure's __new__ and __init__

lib-python/modified-2.7.0/ctypes/test/test_prototypes.py

 from ctypes import *
 import unittest
-from ctypes.test import xfail
 
 # IMPORTANT INFO:
 #

lib-python/modified-2.7.0/ctypes/test/test_refcounts.py

             return a * b * 2
         f = proto(func)
 
+        gc.collect()
         a = sys.getrefcount(ctypes.c_int)
         f(1, 2)
         self.assertEqual(sys.getrefcount(ctypes.c_int), a)

lib-python/modified-2.7.0/test/test_ast.py

                 self._assertTrueorder(value, parent_pos)
 
     def test_AST_objects(self):
-        x = ast.AST()
-        try:
-            x.foobar = 21
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'_ast.AST' object has no attribute 'foobar'")
-        else:
-            self.assert_(False)
+        if test_support.check_impl_detail():
+            # PyPy also provides a __dict__ to the ast.AST base class.
 
-        try:
-            ast.AST(lineno=2)
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'_ast.AST' object has no attribute 'lineno'")
-        else:
-            self.assert_(False)
+            x = ast.AST()
+            try:
+                x.foobar = 21
+            except AttributeError, e:
+                self.assertEquals(e.args[0],
+                                  "'_ast.AST' object has no attribute 'foobar'")
+            else:
+                self.assert_(False)
+
+            try:
+                ast.AST(lineno=2)
+            except AttributeError, e:
+                self.assertEquals(e.args[0],
+                                  "'_ast.AST' object has no attribute 'lineno'")
+            else:
+                self.assert_(False)
+
         try:
             ast.AST(2)
         except TypeError, e:

lib_pypy/_ctypes/__init__.py

 from _ctypes.primitive import _SimpleCData
 from _ctypes.pointer import _Pointer, _cast_addr
 from _ctypes.pointer import POINTER, pointer, _pointer_type_cache
-from _ctypes.function import CFuncPtr
+from _ctypes.function import CFuncPtr, call_function
 from _ctypes.dll import dlopen
 from _ctypes.structure import Structure
 from _ctypes.array import Array

lib_pypy/_ctypes/function.py

     from _ctypes import COMError
     return COMError(errcode, None, None)
 
+def call_function(func, args):
+    "Only for debugging so far: So that we can call CFunction instances"
+    funcptr = CFuncPtr(func)
+    funcptr.restype = int
+    return funcptr(*args)
+
 class CFuncPtrType(_CDataMeta):
     # XXX write down here defaults and such things
 
     errcheck = property(_geterrcheck, _seterrcheck, _delerrcheck)
 
     def _ffishapes(self, args, restype):
+        if args is None:
+            args = []
         argtypes = [arg._ffiargshape for arg in args]
         if restype is not None:
             if not isinstance(restype, SimpleType):
         return callargs, outargs
 
     def __nonzero__(self):
-        return bool(self._buffer[0])
+        return self._com_index is not None or bool(self._buffer[0])
 
     def __del__(self):
         if self._needs_free:

lib_pypy/_ctypes/structure.py

     __setattr__ = struct_setattr
 
     def from_address(self, address):
-        instance = self.__new__(self)
+        instance = StructOrUnion.__new__(self)
         instance.__dict__['_buffer'] = self._ffistruct.fromaddress(address)
         return instance
 
         return _CDataMeta.from_param(self, value)
 
     def _CData_output(self, resarray, base=None, index=-1):
-        res = self.__new__(self)
+        res = StructOrUnion.__new__(self)
         ffistruct = self._ffistruct.fromaddress(resarray.buffer)
         res.__dict__['_buffer'] = ffistruct
         res.__dict__['_base'] = base
         return res
     
     def _CData_retval(self, resbuffer):
-        res = self.__new__(self)
+        res = StructOrUnion.__new__(self)
         res.__dict__['_buffer'] = resbuffer
         res.__dict__['_base'] = None
         res.__dict__['_index'] = -1

pypy/interpreter/astcompiler/ast.py

         return space.wrap(node)
     return func_with_new_name(generic_AST_new, "new_%s" % node_class.__name__)
 
+def AST_init(space, w_self, __args__):
+    args_w, kwargs_w = __args__.unpack()
+    if args_w and len(args_w) != 0:
+        w_err = space.wrap("_ast.AST constructor takes 0 positional arguments")
+        raise OperationError(space.w_TypeError, w_err)
+    for field, w_value in kwargs_w.iteritems():
+        space.setattr(w_self, space.wrap(field), w_value)
 
 AST.typedef = typedef.TypeDef("AST",
     _fields=_FieldsWrapper([]),
     __setstate__=interp2app(AST.setstate_w),
     __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
                                       typedef.descr_set_dict, cls=AST),
+    __new__=interp2app(get_AST_new(AST)),
+    __init__=interp2app(AST_init),
 )
-AST.typedef.acceptable_as_base_class = False
 
 
 def missing_field(space, state, required, host):
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(mod)),
 )
-mod.typedef.acceptable_as_base_class = False
 
 def Module_get_body(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Module constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Module constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Module_field_unroller:
     __new__=interp2app(get_AST_new(Module)),
     __init__=interp2app(Module_init),
 )
-Module.typedef.acceptable_as_base_class = False
 
 def Interactive_get_body(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Interactive constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Interactive constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Interactive_field_unroller:
     __new__=interp2app(get_AST_new(Interactive)),
     __init__=interp2app(Interactive_init),
 )
-Interactive.typedef.acceptable_as_base_class = False
 
 def Expression_get_body(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Expression constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Expression constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Expression_field_unroller:
     __new__=interp2app(get_AST_new(Expression)),
     __init__=interp2app(Expression_init),
 )
-Expression.typedef.acceptable_as_base_class = False
 
 def Suite_get_body(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Suite constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Suite constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Suite_field_unroller:
     __new__=interp2app(get_AST_new(Suite)),
     __init__=interp2app(Suite_init),
 )
-Suite.typedef.acceptable_as_base_class = False
 
 def stmt_get_lineno(space, w_self):
     if w_self.w_dict is not None:
     _attributes=_FieldsWrapper(['lineno', 'col_offset']),
     lineno=typedef.GetSetProperty(stmt_get_lineno, stmt_set_lineno, cls=stmt),
     col_offset=typedef.GetSetProperty(stmt_get_col_offset, stmt_set_col_offset, cls=stmt),
+    __new__=interp2app(get_AST_new(stmt)),
 )
-stmt.typedef.acceptable_as_base_class = False
 
 def FunctionDef_get_name(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 4:
-            w_err = space.wrap("FunctionDef constructor takes 0 or 4 positional arguments")
+            w_err = space.wrap("FunctionDef constructor takes either 0 or 4 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _FunctionDef_field_unroller:
     __new__=interp2app(get_AST_new(FunctionDef)),
     __init__=interp2app(FunctionDef_init),
 )
-FunctionDef.typedef.acceptable_as_base_class = False
 
 def ClassDef_get_name(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 4:
-            w_err = space.wrap("ClassDef constructor takes 0 or 4 positional arguments")
+            w_err = space.wrap("ClassDef constructor takes either 0 or 4 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _ClassDef_field_unroller:
     __new__=interp2app(get_AST_new(ClassDef)),
     __init__=interp2app(ClassDef_init),
 )
-ClassDef.typedef.acceptable_as_base_class = False
 
 def Return_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Return constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Return constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Return_field_unroller:
     __new__=interp2app(get_AST_new(Return)),
     __init__=interp2app(Return_init),
 )
-Return.typedef.acceptable_as_base_class = False
 
 def Delete_get_targets(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Delete constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Delete constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Delete_field_unroller:
     __new__=interp2app(get_AST_new(Delete)),
     __init__=interp2app(Delete_init),
 )
-Delete.typedef.acceptable_as_base_class = False
 
 def Assign_get_targets(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Assign constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Assign constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Assign_field_unroller:
     __new__=interp2app(get_AST_new(Assign)),
     __init__=interp2app(Assign_init),
 )
-Assign.typedef.acceptable_as_base_class = False
 
 def AugAssign_get_target(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("AugAssign constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("AugAssign constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _AugAssign_field_unroller:
     __new__=interp2app(get_AST_new(AugAssign)),
     __init__=interp2app(AugAssign_init),
 )
-AugAssign.typedef.acceptable_as_base_class = False
 
 def Print_get_dest(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Print constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Print constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Print_field_unroller:
     __new__=interp2app(get_AST_new(Print)),
     __init__=interp2app(Print_init),
 )
-Print.typedef.acceptable_as_base_class = False
 
 def For_get_target(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 4:
-            w_err = space.wrap("For constructor takes 0 or 4 positional arguments")
+            w_err = space.wrap("For constructor takes either 0 or 4 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _For_field_unroller:
     __new__=interp2app(get_AST_new(For)),
     __init__=interp2app(For_init),
 )
-For.typedef.acceptable_as_base_class = False
 
 def While_get_test(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("While constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("While constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _While_field_unroller:
     __new__=interp2app(get_AST_new(While)),
     __init__=interp2app(While_init),
 )
-While.typedef.acceptable_as_base_class = False
 
 def If_get_test(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("If constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("If constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _If_field_unroller:
     __new__=interp2app(get_AST_new(If)),
     __init__=interp2app(If_init),
 )
-If.typedef.acceptable_as_base_class = False
 
 def With_get_context_expr(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("With constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("With constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _With_field_unroller:
     __new__=interp2app(get_AST_new(With)),
     __init__=interp2app(With_init),
 )
-With.typedef.acceptable_as_base_class = False
 
 def Raise_get_type(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Raise constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Raise constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Raise_field_unroller:
     __new__=interp2app(get_AST_new(Raise)),
     __init__=interp2app(Raise_init),
 )
-Raise.typedef.acceptable_as_base_class = False
 
 def TryExcept_get_body(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("TryExcept constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("TryExcept constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _TryExcept_field_unroller:
     __new__=interp2app(get_AST_new(TryExcept)),
     __init__=interp2app(TryExcept_init),
 )
-TryExcept.typedef.acceptable_as_base_class = False
 
 def TryFinally_get_body(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("TryFinally constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("TryFinally constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _TryFinally_field_unroller:
     __new__=interp2app(get_AST_new(TryFinally)),
     __init__=interp2app(TryFinally_init),
 )
-TryFinally.typedef.acceptable_as_base_class = False
 
 def Assert_get_test(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Assert constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Assert constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Assert_field_unroller:
     __new__=interp2app(get_AST_new(Assert)),
     __init__=interp2app(Assert_init),
 )
-Assert.typedef.acceptable_as_base_class = False
 
 def Import_get_names(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Import constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Import constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Import_field_unroller:
     __new__=interp2app(get_AST_new(Import)),
     __init__=interp2app(Import_init),
 )
-Import.typedef.acceptable_as_base_class = False
 
 def ImportFrom_get_module(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("ImportFrom constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("ImportFrom constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _ImportFrom_field_unroller:
     __new__=interp2app(get_AST_new(ImportFrom)),
     __init__=interp2app(ImportFrom_init),
 )
-ImportFrom.typedef.acceptable_as_base_class = False
 
 def Exec_get_body(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Exec constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Exec constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Exec_field_unroller:
     __new__=interp2app(get_AST_new(Exec)),
     __init__=interp2app(Exec_init),
 )
-Exec.typedef.acceptable_as_base_class = False
 
 def Global_get_names(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Global constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Global constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Global_field_unroller:
     __new__=interp2app(get_AST_new(Global)),
     __init__=interp2app(Global_init),
 )
-Global.typedef.acceptable_as_base_class = False
 
 def Expr_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Expr constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Expr constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Expr_field_unroller:
     __new__=interp2app(get_AST_new(Expr)),
     __init__=interp2app(Expr_init),
 )
-Expr.typedef.acceptable_as_base_class = False
 
 def Pass_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Pass, w_self)
     __new__=interp2app(get_AST_new(Pass)),
     __init__=interp2app(Pass_init),
 )
-Pass.typedef.acceptable_as_base_class = False
 
 def Break_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Break, w_self)
     __new__=interp2app(get_AST_new(Break)),
     __init__=interp2app(Break_init),
 )
-Break.typedef.acceptable_as_base_class = False
 
 def Continue_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Continue, w_self)
     __new__=interp2app(get_AST_new(Continue)),
     __init__=interp2app(Continue_init),
 )
-Continue.typedef.acceptable_as_base_class = False
 
 def expr_get_lineno(space, w_self):
     if w_self.w_dict is not None:
     _attributes=_FieldsWrapper(['lineno', 'col_offset']),
     lineno=typedef.GetSetProperty(expr_get_lineno, expr_set_lineno, cls=expr),
     col_offset=typedef.GetSetProperty(expr_get_col_offset, expr_set_col_offset, cls=expr),
+    __new__=interp2app(get_AST_new(expr)),
 )
-expr.typedef.acceptable_as_base_class = False
 
 def BoolOp_get_op(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("BoolOp constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("BoolOp constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _BoolOp_field_unroller:
     __new__=interp2app(get_AST_new(BoolOp)),
     __init__=interp2app(BoolOp_init),
 )
-BoolOp.typedef.acceptable_as_base_class = False
 
 def BinOp_get_left(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("BinOp constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("BinOp constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _BinOp_field_unroller:
     __new__=interp2app(get_AST_new(BinOp)),
     __init__=interp2app(BinOp_init),
 )
-BinOp.typedef.acceptable_as_base_class = False
 
 def UnaryOp_get_op(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("UnaryOp constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("UnaryOp constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _UnaryOp_field_unroller:
     __new__=interp2app(get_AST_new(UnaryOp)),
     __init__=interp2app(UnaryOp_init),
 )
-UnaryOp.typedef.acceptable_as_base_class = False
 
 def Lambda_get_args(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Lambda constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Lambda constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Lambda_field_unroller:
     __new__=interp2app(get_AST_new(Lambda)),
     __init__=interp2app(Lambda_init),
 )
-Lambda.typedef.acceptable_as_base_class = False
 
 def IfExp_get_test(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("IfExp constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("IfExp constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _IfExp_field_unroller:
     __new__=interp2app(get_AST_new(IfExp)),
     __init__=interp2app(IfExp_init),
 )
-IfExp.typedef.acceptable_as_base_class = False
 
 def Dict_get_keys(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Dict constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Dict constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Dict_field_unroller:
     __new__=interp2app(get_AST_new(Dict)),
     __init__=interp2app(Dict_init),
 )
-Dict.typedef.acceptable_as_base_class = False
 
 def Set_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Set constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Set constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Set_field_unroller:
     __new__=interp2app(get_AST_new(Set)),
     __init__=interp2app(Set_init),
 )
-Set.typedef.acceptable_as_base_class = False
 
 def ListComp_get_elt(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("ListComp constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("ListComp constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _ListComp_field_unroller:
     __new__=interp2app(get_AST_new(ListComp)),
     __init__=interp2app(ListComp_init),
 )
-ListComp.typedef.acceptable_as_base_class = False
 
 def SetComp_get_elt(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("SetComp constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("SetComp constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _SetComp_field_unroller:
     __new__=interp2app(get_AST_new(SetComp)),
     __init__=interp2app(SetComp_init),
 )
-SetComp.typedef.acceptable_as_base_class = False
 
 def DictComp_get_key(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("DictComp constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("DictComp constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _DictComp_field_unroller:
     __new__=interp2app(get_AST_new(DictComp)),
     __init__=interp2app(DictComp_init),
 )
-DictComp.typedef.acceptable_as_base_class = False
 
 def GeneratorExp_get_elt(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("GeneratorExp constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("GeneratorExp constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _GeneratorExp_field_unroller:
     __new__=interp2app(get_AST_new(GeneratorExp)),
     __init__=interp2app(GeneratorExp_init),
 )
-GeneratorExp.typedef.acceptable_as_base_class = False
 
 def Yield_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Yield constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Yield constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Yield_field_unroller:
     __new__=interp2app(get_AST_new(Yield)),
     __init__=interp2app(Yield_init),
 )
-Yield.typedef.acceptable_as_base_class = False
 
 def Compare_get_left(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Compare constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Compare constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Compare_field_unroller:
     __new__=interp2app(get_AST_new(Compare)),
     __init__=interp2app(Compare_init),
 )
-Compare.typedef.acceptable_as_base_class = False
 
 def Call_get_func(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 5:
-            w_err = space.wrap("Call constructor takes 0 or 5 positional arguments")
+            w_err = space.wrap("Call constructor takes either 0 or 5 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Call_field_unroller:
     __new__=interp2app(get_AST_new(Call)),
     __init__=interp2app(Call_init),
 )
-Call.typedef.acceptable_as_base_class = False
 
 def Repr_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Repr constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Repr constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Repr_field_unroller:
     __new__=interp2app(get_AST_new(Repr)),
     __init__=interp2app(Repr_init),
 )
-Repr.typedef.acceptable_as_base_class = False
 
 def Num_get_n(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Num constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Num constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Num_field_unroller:
     __new__=interp2app(get_AST_new(Num)),
     __init__=interp2app(Num_init),
 )
-Num.typedef.acceptable_as_base_class = False
 
 def Str_get_s(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Str constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Str constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Str_field_unroller:
     __new__=interp2app(get_AST_new(Str)),
     __init__=interp2app(Str_init),
 )
-Str.typedef.acceptable_as_base_class = False
 
 def Attribute_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Attribute constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Attribute constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Attribute_field_unroller:
     __new__=interp2app(get_AST_new(Attribute)),
     __init__=interp2app(Attribute_init),
 )
-Attribute.typedef.acceptable_as_base_class = False
 
 def Subscript_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Subscript constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Subscript constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Subscript_field_unroller:
     __new__=interp2app(get_AST_new(Subscript)),
     __init__=interp2app(Subscript_init),
 )
-Subscript.typedef.acceptable_as_base_class = False
 
 def Name_get_id(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Name constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Name constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Name_field_unroller:
     __new__=interp2app(get_AST_new(Name)),
     __init__=interp2app(Name_init),
 )
-Name.typedef.acceptable_as_base_class = False
 
 def List_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("List constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("List constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _List_field_unroller:
     __new__=interp2app(get_AST_new(List)),
     __init__=interp2app(List_init),
 )
-List.typedef.acceptable_as_base_class = False
 
 def Tuple_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("Tuple constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("Tuple constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Tuple_field_unroller:
     __new__=interp2app(get_AST_new(Tuple)),
     __init__=interp2app(Tuple_init),
 )
-Tuple.typedef.acceptable_as_base_class = False
 
 def Const_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Const constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Const constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Const_field_unroller:
     __new__=interp2app(get_AST_new(Const)),
     __init__=interp2app(Const_init),
 )
-Const.typedef.acceptable_as_base_class = False
 
 expr_context.typedef = typedef.TypeDef("expr_context",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(expr_context)),
 )
-expr_context.typedef.acceptable_as_base_class = False
 
 _Load.typedef = typedef.TypeDef("Load",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Load)),
 )
-_Load.typedef.acceptable_as_base_class = False
 
 _Store.typedef = typedef.TypeDef("Store",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Store)),
 )
-_Store.typedef.acceptable_as_base_class = False
 
 _Del.typedef = typedef.TypeDef("Del",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Del)),
 )
-_Del.typedef.acceptable_as_base_class = False
 
 _AugLoad.typedef = typedef.TypeDef("AugLoad",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_AugLoad)),
 )
-_AugLoad.typedef.acceptable_as_base_class = False
 
 _AugStore.typedef = typedef.TypeDef("AugStore",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_AugStore)),
 )
-_AugStore.typedef.acceptable_as_base_class = False
 
 _Param.typedef = typedef.TypeDef("Param",
     expr_context.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Param)),
 )
-_Param.typedef.acceptable_as_base_class = False
 
 slice.typedef = typedef.TypeDef("slice",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(slice)),
 )
-slice.typedef.acceptable_as_base_class = False
 
 def Ellipsis_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Ellipsis, w_self)
     __new__=interp2app(get_AST_new(Ellipsis)),
     __init__=interp2app(Ellipsis_init),
 )
-Ellipsis.typedef.acceptable_as_base_class = False
 
 def Slice_get_lower(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("Slice constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("Slice constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Slice_field_unroller:
     __new__=interp2app(get_AST_new(Slice)),
     __init__=interp2app(Slice_init),
 )
-Slice.typedef.acceptable_as_base_class = False
 
 def ExtSlice_get_dims(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("ExtSlice constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("ExtSlice constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _ExtSlice_field_unroller:
     __new__=interp2app(get_AST_new(ExtSlice)),
     __init__=interp2app(ExtSlice_init),
 )
-ExtSlice.typedef.acceptable_as_base_class = False
 
 def Index_get_value(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 1:
-            w_err = space.wrap("Index constructor takes 0 or 1 positional arguments")
+            w_err = space.wrap("Index constructor takes either 0 or 1 positional argument")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _Index_field_unroller:
     __new__=interp2app(get_AST_new(Index)),
     __init__=interp2app(Index_init),
 )
-Index.typedef.acceptable_as_base_class = False
 
 boolop.typedef = typedef.TypeDef("boolop",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(boolop)),
 )
-boolop.typedef.acceptable_as_base_class = False
 
 _And.typedef = typedef.TypeDef("And",
     boolop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_And)),
 )
-_And.typedef.acceptable_as_base_class = False
 
 _Or.typedef = typedef.TypeDef("Or",
     boolop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Or)),
 )
-_Or.typedef.acceptable_as_base_class = False
 
 operator.typedef = typedef.TypeDef("operator",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(operator)),
 )
-operator.typedef.acceptable_as_base_class = False
 
 _Add.typedef = typedef.TypeDef("Add",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Add)),
 )
-_Add.typedef.acceptable_as_base_class = False
 
 _Sub.typedef = typedef.TypeDef("Sub",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Sub)),
 )
-_Sub.typedef.acceptable_as_base_class = False
 
 _Mult.typedef = typedef.TypeDef("Mult",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Mult)),
 )
-_Mult.typedef.acceptable_as_base_class = False
 
 _Div.typedef = typedef.TypeDef("Div",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Div)),
 )
-_Div.typedef.acceptable_as_base_class = False
 
 _Mod.typedef = typedef.TypeDef("Mod",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Mod)),
 )
-_Mod.typedef.acceptable_as_base_class = False
 
 _Pow.typedef = typedef.TypeDef("Pow",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Pow)),
 )
-_Pow.typedef.acceptable_as_base_class = False
 
 _LShift.typedef = typedef.TypeDef("LShift",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_LShift)),
 )
-_LShift.typedef.acceptable_as_base_class = False
 
 _RShift.typedef = typedef.TypeDef("RShift",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_RShift)),
 )
-_RShift.typedef.acceptable_as_base_class = False
 
 _BitOr.typedef = typedef.TypeDef("BitOr",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_BitOr)),
 )
-_BitOr.typedef.acceptable_as_base_class = False
 
 _BitXor.typedef = typedef.TypeDef("BitXor",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_BitXor)),
 )
-_BitXor.typedef.acceptable_as_base_class = False
 
 _BitAnd.typedef = typedef.TypeDef("BitAnd",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_BitAnd)),
 )
-_BitAnd.typedef.acceptable_as_base_class = False
 
 _FloorDiv.typedef = typedef.TypeDef("FloorDiv",
     operator.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_FloorDiv)),
 )
-_FloorDiv.typedef.acceptable_as_base_class = False
 
 unaryop.typedef = typedef.TypeDef("unaryop",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(unaryop)),
 )
-unaryop.typedef.acceptable_as_base_class = False
 
 _Invert.typedef = typedef.TypeDef("Invert",
     unaryop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Invert)),
 )
-_Invert.typedef.acceptable_as_base_class = False
 
 _Not.typedef = typedef.TypeDef("Not",
     unaryop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Not)),
 )
-_Not.typedef.acceptable_as_base_class = False
 
 _UAdd.typedef = typedef.TypeDef("UAdd",
     unaryop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_UAdd)),
 )
-_UAdd.typedef.acceptable_as_base_class = False
 
 _USub.typedef = typedef.TypeDef("USub",
     unaryop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_USub)),
 )
-_USub.typedef.acceptable_as_base_class = False
 
 cmpop.typedef = typedef.TypeDef("cmpop",
     AST.typedef,
     __module__='_ast',
     _attributes=_FieldsWrapper([]),
+    __new__=interp2app(get_AST_new(cmpop)),
 )
-cmpop.typedef.acceptable_as_base_class = False
 
 _Eq.typedef = typedef.TypeDef("Eq",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Eq)),
 )
-_Eq.typedef.acceptable_as_base_class = False
 
 _NotEq.typedef = typedef.TypeDef("NotEq",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_NotEq)),
 )
-_NotEq.typedef.acceptable_as_base_class = False
 
 _Lt.typedef = typedef.TypeDef("Lt",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Lt)),
 )
-_Lt.typedef.acceptable_as_base_class = False
 
 _LtE.typedef = typedef.TypeDef("LtE",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_LtE)),
 )
-_LtE.typedef.acceptable_as_base_class = False
 
 _Gt.typedef = typedef.TypeDef("Gt",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Gt)),
 )
-_Gt.typedef.acceptable_as_base_class = False
 
 _GtE.typedef = typedef.TypeDef("GtE",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_GtE)),
 )
-_GtE.typedef.acceptable_as_base_class = False
 
 _Is.typedef = typedef.TypeDef("Is",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_Is)),
 )
-_Is.typedef.acceptable_as_base_class = False
 
 _IsNot.typedef = typedef.TypeDef("IsNot",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_IsNot)),
 )
-_IsNot.typedef.acceptable_as_base_class = False
 
 _In.typedef = typedef.TypeDef("In",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_In)),
 )
-_In.typedef.acceptable_as_base_class = False
 
 _NotIn.typedef = typedef.TypeDef("NotIn",
     cmpop.typedef,
     _fields=_FieldsWrapper([]),
     __new__=interp2app(get_AST_new(_NotIn)),
 )
-_NotIn.typedef.acceptable_as_base_class = False
 
 def comprehension_get_target(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("comprehension constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("comprehension constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _comprehension_field_unroller:
     __new__=interp2app(get_AST_new(comprehension)),
     __init__=interp2app(comprehension_init),
 )
-comprehension.typedef.acceptable_as_base_class = False
 
 def excepthandler_get_lineno(space, w_self):
     if w_self.w_dict is not None:
     _attributes=_FieldsWrapper(['lineno', 'col_offset']),
     lineno=typedef.GetSetProperty(excepthandler_get_lineno, excepthandler_set_lineno, cls=excepthandler),
     col_offset=typedef.GetSetProperty(excepthandler_get_col_offset, excepthandler_set_col_offset, cls=excepthandler),
+    __new__=interp2app(get_AST_new(excepthandler)),
 )
-excepthandler.typedef.acceptable_as_base_class = False
 
 def ExceptHandler_get_type(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 3:
-            w_err = space.wrap("ExceptHandler constructor takes 0 or 3 positional arguments")
+            w_err = space.wrap("ExceptHandler constructor takes either 0 or 3 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _ExceptHandler_field_unroller:
     __new__=interp2app(get_AST_new(ExceptHandler)),
     __init__=interp2app(ExceptHandler_init),
 )
-ExceptHandler.typedef.acceptable_as_base_class = False
 
 def arguments_get_args(space, w_self):
     if not w_self.initialization_state & 1:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 4:
-            w_err = space.wrap("arguments constructor takes 0 or 4 positional arguments")
+            w_err = space.wrap("arguments constructor takes either 0 or 4 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _arguments_field_unroller:
     __new__=interp2app(get_AST_new(arguments)),
     __init__=interp2app(arguments_init),
 )
-arguments.typedef.acceptable_as_base_class = False
 
 def keyword_get_arg(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("keyword constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("keyword constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _keyword_field_unroller:
     __new__=interp2app(get_AST_new(keyword)),
     __init__=interp2app(keyword_init),
 )
-keyword.typedef.acceptable_as_base_class = False
 
 def alias_get_name(space, w_self):
     if w_self.w_dict is not None:
     args_w, kwargs_w = __args__.unpack()
     if args_w:
         if len(args_w) != 2:
-            w_err = space.wrap("alias constructor takes 0 or 2 positional arguments")
+            w_err = space.wrap("alias constructor takes either 0 or 2 positional arguments")
             raise OperationError(space.w_TypeError, w_err)
         i = 0
         for field in _alias_field_unroller:
     __new__=interp2app(get_AST_new(alias)),
     __init__=interp2app(alias_init),
 )
-alias.typedef.acceptable_as_base_class = False
-
+

pypy/interpreter/astcompiler/tools/asdl_py.py

             setter = "%s_set_%s" % (name, field.name)
             config = (field.name, getter, setter, name)
             self.emit("%s=typedef.GetSetProperty(%s, %s, cls=%s)," % config, 1)
-        # CPython lets you create instances of "abstract" AST nodes
-        # like ast.expr or even ast.AST.  This doesn't seem to useful
-        # and would be a pain to implement safely, so we don't allow
-        # it.
-        if concrete:
-            self.emit("__new__=interp2app(get_AST_new(%s))," % (name,), 1)
-            if needs_init:
-                self.emit("__init__=interp2app(%s_init)," % (name,), 1)
+        self.emit("__new__=interp2app(get_AST_new(%s))," % (name,), 1)
+        if needs_init:
+            self.emit("__init__=interp2app(%s_init)," % (name,), 1)
         self.emit(")")
-        self.emit("%s.typedef.acceptable_as_base_class = False" % (name,))
         self.emit("")
 
     def make_init(self, name, fields):
         arity = len(fields)
         if arity:
             self.emit("if len(args_w) != %i:" % (arity,), 2)
-            self.emit("w_err = space.wrap(\"%s constructor takes 0 or %i " \
-                          "positional arguments\")" % (name, arity), 3)
+            plural = arity > 1 and "s" or ""
+            self.emit("w_err = space.wrap(\"%s constructor takes either 0 or %i " \
+                          "positional argument%s\")" % (name, arity, plural), 3)
             self.emit("raise OperationError(space.w_TypeError, w_err)", 3)
             self.emit("i = 0", 2)
             self.emit("for field in _%s_field_unroller:" % (name,), 2)
         return space.wrap(node)
     return func_with_new_name(generic_AST_new, "new_%s" % node_class.__name__)
 
+def AST_init(space, w_self, __args__):
+    args_w, kwargs_w = __args__.unpack()
+    if args_w and len(args_w) != 0:
+        w_err = space.wrap("_ast.AST constructor takes 0 positional arguments")
+        raise OperationError(space.w_TypeError, w_err)
+    for field, w_value in kwargs_w.iteritems():
+        space.setattr(w_self, space.wrap(field), w_value)
 
 AST.typedef = typedef.TypeDef("AST",
     _fields=_FieldsWrapper([]),
     __setstate__=interp2app(AST.setstate_w),
     __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
                                       typedef.descr_set_dict, cls=AST),
+    __new__=interp2app(get_AST_new(AST)),
+    __init__=interp2app(AST_init),
 )
-AST.typedef.acceptable_as_base_class = False
 
 
 def missing_field(space, state, required, host):

pypy/module/_ast/test/test_ast.py

 
     def test_abstract_ast_types(self):
         ast = self.ast
-        raises(TypeError, ast.expr)
-        raises(TypeError, ast.AST)
-        raises(TypeError, type, "X", (ast.AST,), {})
-        raises(TypeError, type, "Y", (ast.expr,), {})
+        ast.expr()
+        ast.AST()
+        class X(ast.AST):
+            pass
+        X()
+        class Y(ast.expr):
+            pass
+        Y()
+        exc = raises(TypeError, ast.AST, 2)
+        assert exc.value.args[0] == "_ast.AST constructor takes 0 positional arguments"
 
     def test_constructor(self):
         ast = self.ast
         assert fr.col_offset == 1
         exc = raises(TypeError, ast.Module, 1, 2).value
         msg = str(exc)
-        assert msg == "Module constructor takes 0 or 1 positional arguments"
+        assert msg == "Module constructor takes either 0 or 1 positional argument"
         ast.Module(nothing=23)
 
     def test_future(self):