[pypy-svn] r49743 - in pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Dec 13 21:55:44 CET 2007


Author: cfbolz
Date: Thu Dec 13 21:55:43 2007
New Revision: 49743

Modified:
   pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
   pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
Log:
a missing helper function. tests that hit the problem


Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py	(original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py	Thu Dec 13 21:55:43 2007
@@ -8,6 +8,13 @@
 from pypy.rlib.rarithmetic import r_uint, intmask
 
 
+def raise_type_err(space, argument, expected, w_obj):
+    type_name = space.type(w_obj).getname(space, '?')
+    w_error = space.wrap("argument %s must be %s, not %s" % (
+        argument, expected, type_name))
+    raise OperationError(space.w_TypeError,
+                         w_error)
+
 def descr_classobj_new(space, w_subtype, w_name, w_bases, w_dict):
     if not space.is_true(space.isinstance(w_bases, space.w_tuple)):
         raise_type_err(space, 'bases', 'tuple', w_bases)

Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py	(original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py	Thu Dec 13 21:55:43 2007
@@ -612,3 +612,7 @@
 
     def test_class_instantiation_bug(self):
         raises(TypeError, "class A(1, 2): __metaclass__ = nclassobj")
+        raises(TypeError, "nclassobj(1, (), {})")
+        raises(TypeError, "nclassobj('abc', 1, {})")
+        raises(TypeError, "nclassobj('abc', (1, ), {})")
+        raises(TypeError, "nclassobj('abc', (), 3)")



More information about the Pypy-commit mailing list