[pypy-svn] r56489 - in pypy/dist: demo/sqlinj lib-python lib-python/modified-2.4.1 lib-python/modified-2.4.1/test pypy pypy/config pypy/doc/config pypy/interpreter pypy/interpreter/test pypy/module/__builtin__ pypy/module/__builtin__/test pypy/module/operator/test pypy/objspace/std pypy/objspace/std/test pypy/objspace/test pypy/translator/goal

arigo at codespeak.net arigo at codespeak.net
Sat Jul 12 14:55:46 CEST 2008


Author: arigo
Date: Sat Jul 12 14:55:43 2008
New Revision: 56489

Removed:
   pypy/dist/demo/sqlinj/
   pypy/dist/lib-python/modified-2.4.1/types.py
   pypy/dist/pypy/doc/config/objspace.std.oldstyle.txt
Modified:
   pypy/dist/lib-python/conftest.py
   pypy/dist/lib-python/modified-2.4.1/test/test_repr.py
   pypy/dist/pypy/config/pypyoption.py
   pypy/dist/pypy/conftest.py
   pypy/dist/pypy/interpreter/baseobjspace.py
   pypy/dist/pypy/interpreter/test/test_appinterp.py
   pypy/dist/pypy/interpreter/test/test_class.py
   pypy/dist/pypy/interpreter/test/test_compiler.py
   pypy/dist/pypy/interpreter/test/test_exec.py
   pypy/dist/pypy/interpreter/test/test_function.py
   pypy/dist/pypy/interpreter/test/test_interpreter.py
   pypy/dist/pypy/interpreter/test/test_objspace.py
   pypy/dist/pypy/interpreter/test/test_raise.py
   pypy/dist/pypy/module/__builtin__/__init__.py
   pypy/dist/pypy/module/__builtin__/operation.py
   pypy/dist/pypy/module/__builtin__/test/test_builtin.py
   pypy/dist/pypy/module/__builtin__/test/test_classobj.py
   pypy/dist/pypy/module/__builtin__/test/test_descriptor.py
   pypy/dist/pypy/module/__builtin__/test/test_functional.py
   pypy/dist/pypy/module/__builtin__/test/test_reduce.py
   pypy/dist/pypy/module/__builtin__/test/test_vars.py
   pypy/dist/pypy/module/operator/test/test_operator.py
   pypy/dist/pypy/objspace/std/objspace.py
   pypy/dist/pypy/objspace/std/test/test_complexobject.py
   pypy/dist/pypy/objspace/std/test/test_dictobject.py
   pypy/dist/pypy/objspace/std/test/test_floatobject.py
   pypy/dist/pypy/objspace/std/test/test_index.py
   pypy/dist/pypy/objspace/std/test/test_intobject.py
   pypy/dist/pypy/objspace/std/test/test_iterobject.py
   pypy/dist/pypy/objspace/std/test/test_proxy_function.py
   pypy/dist/pypy/objspace/std/test/test_proxy_internals.py
   pypy/dist/pypy/objspace/std/test/test_stringobject.py
   pypy/dist/pypy/objspace/std/test/test_typeobject.py
   pypy/dist/pypy/objspace/std/test/test_unicodeobject.py
   pypy/dist/pypy/objspace/std/test/test_userobject.py
   pypy/dist/pypy/objspace/test/test_descriptor.py
   pypy/dist/pypy/translator/goal/app_main.py
Log:
(fijal, arigo) Merge the always-oldstyle branch:

Remove the --oldstyle option.  Fix a few small bugs in the tests.
Port hopefully all tests that used "class A:" to create new-style
classes.  Kill old broken demo.



Modified: pypy/dist/lib-python/conftest.py
==============================================================================
--- pypy/dist/lib-python/conftest.py	(original)
+++ pypy/dist/lib-python/conftest.py	Sat Jul 12 14:55:43 2008
@@ -297,24 +297,16 @@
 class RegrTest: 
     """ Regression Test Declaration.""" 
     def __init__(self, basename, enabled=False, dumbtest=False,
-                                 oldstyle=False, core=False,
+                                 core=False,
                                  compiler=None, 
                                  usemodules = ''): 
         self.basename = basename 
         self.enabled = enabled 
         self.dumbtest = dumbtest 
-        # we have to determine the value of oldstyle
-        # lazily because at RegrTest() call time the command
-        # line options haven't been parsed!
-        self._oldstyle = oldstyle 
         self._usemodules = usemodules.split()
         self._compiler = compiler 
         self.core = core
 
-    def oldstyle(self): 
-        return self._oldstyle #or pypy_option.oldstyle 
-    oldstyle = property(oldstyle)
-
     def usemodules(self):
         return self._usemodules #+ pypy_option.usemodules
     usemodules = property(usemodules)
@@ -325,7 +317,7 @@
 
     def getoptions(self): 
         l = []
-        for name in 'oldstyle', 'core': 
+        for name in ['core']:
             if getattr(self, name): 
                 l.append(name)
         for name in self.usemodules: 
@@ -365,18 +357,13 @@
         self._prepare(space)
         fspath = self.getfspath()
         assert fspath.check()
-        if self.oldstyle: 
-            space.enable_old_style_classes_as_default_metaclass() 
-        try: 
-            modname = fspath.purebasename 
-            space.appexec([], '''():
-                from test import %(modname)s
-                m = %(modname)s
-                if hasattr(m, 'test_main'):
-                    m.test_main()
-            ''' % locals())
-        finally: 
-            space.enable_new_style_classes_as_default_metaclass() 
+        modname = fspath.purebasename 
+        space.appexec([], '''():
+            from test import %(modname)s
+            m = %(modname)s
+            if hasattr(m, 'test_main'):
+                m.test_main()
+        ''' % locals())
 
 testmap = [
     RegrTest('test___all__.py', enabled=True, core=True),
@@ -422,7 +409,7 @@
     RegrTest('test_cgi.py', enabled=True),
     RegrTest('test_charmapcodec.py', enabled=True, core=True),
     RegrTest('test_cl.py', enabled=False, dumbtest=1),
-    RegrTest('test_class.py', enabled=True, oldstyle=True, core=True),
+    RegrTest('test_class.py', enabled=True, core=True),
     RegrTest('test_cmath.py', enabled=True, dumbtest=1, core=True),
     RegrTest('test_codeccallbacks.py', enabled=True, core=True),
     RegrTest('test_codecencodings_cn.py', enabled=False),
@@ -438,11 +425,11 @@
     RegrTest('test_codecmaps_tw.py', enabled=False),
     RegrTest('test_codecs.py', enabled=True, core=True),
     RegrTest('test_codeop.py', enabled=True, core=True),
-    RegrTest('test_coercion.py', enabled=True, oldstyle=True, core=True),
+    RegrTest('test_coercion.py', enabled=True, core=True),
     
     RegrTest('test_colorsys.py', enabled=True),
     RegrTest('test_commands.py', enabled=True),
-    RegrTest('test_compare.py', enabled=True, oldstyle=True, core=True),
+    RegrTest('test_compare.py', enabled=True, core=True),
     RegrTest('test_compile.py', enabled=True, core=True),
     RegrTest('test_compiler.py', enabled=True, core=False), # this test tests the compiler package from stdlib
     RegrTest('test_complex.py', enabled=True, core=True),
@@ -463,8 +450,8 @@
     RegrTest('test_decimal.py', enabled=True),
     RegrTest('test_decorators.py', enabled=True, core=True),
     RegrTest('test_deque.py', enabled=True, core=True),
-    RegrTest('test_descr.py', enabled=True, core=True, oldstyle=True, usemodules='_weakref'),
-    RegrTest('test_descrtut.py', enabled=True, core=True, oldstyle=True),
+    RegrTest('test_descr.py', enabled=True, core=True, usemodules='_weakref'),
+    RegrTest('test_descrtut.py', enabled=True, core=True),
     RegrTest('test_dict.py', enabled=True, core=True),
 
     RegrTest('test_difflib.py', enabled=True, dumbtest=1),
@@ -577,7 +564,7 @@
     RegrTest('test_multifile.py', enabled=True),
     RegrTest('test_mutants.py', enabled=True, dumbtest=1, core="possibly"),
     RegrTest('test_netrc.py', enabled=True),
-    RegrTest('test_new.py', enabled=True, core=True, oldstyle=True),
+    RegrTest('test_new.py', enabled=True, core=True),
     RegrTest('test_nis.py', enabled=False),
     RegrTest('test_normalization.py', enabled=False),
     RegrTest('test_ntpath.py', enabled=True, dumbtest=1),
@@ -635,7 +622,7 @@
     RegrTest('test_re.py', enabled=True, core=True),
 
     RegrTest('test_regex.py', enabled=False),
-    RegrTest('test_repr.py', enabled=True, oldstyle=True, core=True),
+    RegrTest('test_repr.py', enabled=True, core=True),
         #rev 10840: 6 of 12 tests fail. Always minor stuff like
         #'<function object at 0x40db3e0c>' != '<built-in function hash>'
 
@@ -903,11 +890,6 @@
         if option.use_compiled:
             execpath, info = getexecutable()        
         pypy_options = []
-        if regrtest.oldstyle: 
-            if (option.use_compiled and
-                not info.get('objspace.std.oldstyle', False)):
-                py.test.skip("old-style classes not available with this pypy-c")
-            pypy_options.append('--oldstyle') 
         if regrtest.compiler:
             pypy_options.append('--compiler=%s' % regrtest.compiler)
         pypy_options.extend(

Modified: pypy/dist/lib-python/modified-2.4.1/test/test_repr.py
==============================================================================
--- pypy/dist/lib-python/modified-2.4.1/test/test_repr.py	(original)
+++ pypy/dist/lib-python/modified-2.4.1/test/test_repr.py	Sat Jul 12 14:55:43 2008
@@ -97,9 +97,6 @@
         eq(r(n), expected)
 
     def test_instance(self):
-        # Disabled for PyPy because it relies on oldstyle class behaviour.
-        # Running the test under oldstyle results in many more other problems
-        # though.
         eq = self.assertEquals
         i1 = ClassWithRepr("a")
         eq(r(i1), repr(i1))
@@ -134,8 +131,9 @@
         # Functions
         eq(repr(hash), '<built-in function hash>')
         # Methods
-        self.failUnless(repr(''.split).find(
-            "bound method str.split of '' at 0x") > -1)
+        self.failUnless('method' in repr(''.split))
+        self.failUnless('str' in repr(''.split))
+        self.failUnless('split' in repr(''.split))
 
     def test_xrange(self):
         import warnings
@@ -174,7 +172,9 @@
     def test_descriptors(self):
         eq = self.assertEquals
         # method descriptors
-        eq(repr(dict.items), "<unbound method dict.items>")
+        self.assert_('method' in repr(dict.items))
+        self.assert_('dict' in repr(dict.items))
+        self.assert_('items' in repr(dict.items))
         # XXX member descriptors
         # XXX attribute descriptors
         # XXX slot descriptors
@@ -222,8 +222,7 @@
                 os.remove(p)
         del sys.path[0]
 
-    def DONOTtest_module(self):
-        # PyPy really doesn't (want to) do these complex module reprs.
+    def test_module(self):
         eq = self.assertEquals
         touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
         from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation

Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py	(original)
+++ pypy/dist/pypy/config/pypyoption.py	Sat Jul 12 14:55:43 2008
@@ -287,10 +287,6 @@
                    "track types that override __getattribute__",
                    default=False),
 
-        BoolOption("oldstyle",
-                   "specify whether the default metaclass should be classobj",
-                   default=False, cmdline="-k --oldstyle"),
-
         BoolOption("logspaceoptypes",
                    "a instrumentation option: before exit, print the types seen by "
                    "certain simpler bytecodes",

Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py	(original)
+++ pypy/dist/pypy/conftest.py	Sat Jul 12 14:55:43 2008
@@ -90,8 +90,6 @@
                                          "module %r required" % (modname,))
                 continue
             if info is None:
-                if key == 'objspace.std.oldstyle' and value:
-                    continue    # fine on CPython
                 py.test.skip("cannot runappdirect this test on top of CPython")
             has = info.get(key, None)
             if has != value:

Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py	Sat Jul 12 14:55:43 2008
@@ -207,7 +207,7 @@
 
     full_exceptions = True  # full support for exceptions (normalization & more)
 
-    def __init__(self, config=None, **kw):
+    def __init__(self, config=None):
         "NOT_RPYTHON: Basic initialization of objects."
         self.fromcache = InternalSpaceCache(self).getorbuild
         self.threadlocals = ThreadLocals()
@@ -227,7 +227,6 @@
         self.frame_trace_action = FrameTraceAction(self)
         self.actionflag.register_action(self.user_del_action)
         self.actionflag.register_action(self.frame_trace_action)
-        self.setoptions(**kw)
 
         from pypy.interpreter.pyframe import PyFrame
         self.FrameClass = PyFrame    # can be overridden to a subclass
@@ -237,10 +236,6 @@
 
         self.initialize()
 
-    def setoptions(self):
-        # override this in subclasses for extra-options
-        pass
-
     def startup(self):
         # To be called before using the space
 
@@ -735,10 +730,15 @@
                 return w_value
         return None
 
+    def is_oldstyle_instance(self, w_obj):
+        # xxx hack hack hack
+        from pypy.module.__builtin__.interp_classobj import W_InstanceObject
+        obj = self.interpclass_w(w_obj)
+        return obj is not None and isinstance(obj, W_InstanceObject)
+
     def callable(self, w_obj):
         if self.lookup(w_obj, "__call__") is not None:
-            w_is_oldstyle = self.isinstance(w_obj, self.w_instance)
-            if self.is_true(w_is_oldstyle):
+            if self.is_oldstyle_instance(w_obj):
                 # ugly old style class special treatment, but well ...
                 try:
                     self.getattr(w_obj, self.wrap("__call__"))

Modified: pypy/dist/pypy/interpreter/test/test_appinterp.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_appinterp.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_appinterp.py	Sat Jul 12 14:55:43 2008
@@ -86,7 +86,7 @@
 
 def test_applevel_class(space, applevel_temp = applevel_temp):
     app = applevel_temp('''
-        class C: 
+        class C(object):
             clsattr = 42 
             def __init__(self, x=13): 
                 self.attr = x 

Modified: pypy/dist/pypy/interpreter/test/test_class.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_class.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_class.py	Sat Jul 12 14:55:43 2008
@@ -46,28 +46,28 @@
         assert c.__class__ == C
 
     def test_method(self):
-        class C:
+        class C(object):
             def meth(self):
                 return 1
         c = C()
         assert c.meth() == 1
 
     def test_method_exc(self):
-        class C:
+        class C(object):
             def meth(self):
                 raise RuntimeError
         c = C()
         raises(RuntimeError, c.meth)
 
     def test_class_attr(self):
-        class C:
+        class C(object):
             a = 42
         c = C()
         assert c.a == 42
         assert C.a == 42
 
     def test_class_attr_inherited(self):
-        class C:
+        class C(object):
             a = 42
         class D(C):
             pass
@@ -110,7 +110,7 @@
         assert float(x) == 5.5
 
     def test_meth_doc(self):
-        class C:
+        class C(object):
             def meth_no_doc(self):
                 pass
             def meth_doc(self):

Modified: pypy/dist/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_compiler.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_compiler.py	Sat Jul 12 14:55:43 2008
@@ -350,7 +350,7 @@
     def test_mangling(self):
         snippet = str(py.code.Source(r'''
             __g = "42"
-            class X:
+            class X(object):
                 def __init__(self, u):
                     self.__u = u
                 def __f(__self, __n):
@@ -390,7 +390,7 @@
 
     def test_chained_access_augassign(self):
         snippet = str(py.code.Source(r'''
-            class R:
+            class R(object):
                count = 0
             c = 0
             for i in [0,1,2]:
@@ -480,7 +480,7 @@
             def f(self):
                 def get_nested_class():
                     self
-                    class Test:
+                    class Test(object):
                         def _STOP_HERE_(self):
                             return _STOP_HERE_(self)
                 get_nested_class()
@@ -496,7 +496,7 @@
         space = self.space
         snippet = str(py.code.Source(r'''
             def f(x):
-                class Test:
+                class Test(object):
                     def meth(self):
                         return x + 1
                 return Test()
@@ -533,7 +533,7 @@
         snippet = str(py.code.Source(r'''
             def f():
                 method_and_var = "var"
-                class Test:
+                class Test(object):
                     def method_and_var(self):
                         return "method"
                     def test(self):
@@ -630,7 +630,7 @@
 class AppTestOptimizer:
     def test_constant_fold_add(self):
         import parser
-        class Folder:
+        class Folder(object):
             def defaultvisit(self, node):
                 return node
 

Modified: pypy/dist/pypy/interpreter/test/test_exec.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_exec.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_exec.py	Sat Jul 12 14:55:43 2008
@@ -119,7 +119,7 @@
     def test_nested_names_are_not_confused(self):
         def get_nested_class():
             method_and_var = "var"
-            class Test:
+            class Test(object):
                 def method_and_var(self):
                     return "method"
                 def test(self):

Modified: pypy/dist/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_function.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_function.py	Sat Jul 12 14:55:43 2008
@@ -191,7 +191,7 @@
     def test_get_get(self):
         # sanxiyn's test from email
         def m(self): return self
-        class C: pass
+        class C(object): pass
         class D(C): pass
         C.m = m
         D.m = C.m
@@ -201,7 +201,7 @@
         assert d.m() == d
 
     def test_method_eq(self):
-        class C:
+        class C(object):
             def m(): pass
         c = C()
         assert C.m == C.m
@@ -229,10 +229,6 @@
         assert repr(A.f) == "<unbound method A.f>"
         assert repr(A().f).startswith("<bound method A.f of <") 
         class B:
-            try:
-                __metaclass__ = _classobj
-            except NameError: # non-pypy, assuming oldstyle implicitely
-                pass
             def f(self):
                 pass
         assert repr(B.f) == "<unbound method B.f>"
@@ -240,13 +236,13 @@
 
 
     def test_method_call(self):
-        class C:
+        class C(object):
             def __init__(self, **kw):
                 pass
         c = C(type='test')
 
     def test_method_w_callable(self):
-        class A:
+        class A(object):
             def __call__(self, x):
                 return x
         import new
@@ -254,7 +250,7 @@
         assert im() == 3
 
     def test_method_w_callable_call_function(self):
-        class A:
+        class A(object):
             def __call__(self, x, y):
                 return x+y
         import new

Modified: pypy/dist/pypy/interpreter/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_interpreter.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_interpreter.py	Sat Jul 12 14:55:43 2008
@@ -263,7 +263,7 @@
     def test_print(self):
         import sys
         save = sys.stdout 
-        class Out:
+        class Out(object):
             def __init__(self):
                 self.args = []
             def write(self, *args):

Modified: pypy/dist/pypy/interpreter/test/test_objspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_objspace.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_objspace.py	Sat Jul 12 14:55:43 2008
@@ -108,7 +108,7 @@
 
         w_oldstyle = self.space.appexec([], """():
             class NoCall:
-                __metaclass__ = _classobj
+                pass
             return NoCall()""")
         assert not is_callable(w_oldstyle)
         self.space.setattr(w_oldstyle, self.space.wrap("__call__"), w_func)

Modified: pypy/dist/pypy/interpreter/test/test_raise.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_raise.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_raise.py	Sat Jul 12 14:55:43 2008
@@ -96,7 +96,7 @@
         raises(StopIteration, f)
 
     def test_userclass(self):
-        class A:
+        class A(object):
             def __init__(self, x=None):
                 self.x = x
         class B(A):
@@ -124,7 +124,8 @@
             assert b.x == 42
 
     def test_it(self):
-        C = _classobj('C', (), {})
+        class C:
+            pass
         # this used to explode in the exception normalization step:
         try:
             {}[C]

Modified: pypy/dist/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/__init__.py	(original)
+++ pypy/dist/pypy/module/__builtin__/__init__.py	Sat Jul 12 14:55:43 2008
@@ -68,11 +68,8 @@
         'file'          : 'state.get(space).w_file',
         'open'          : 'state.get(space).w_file',
 
-        # old-style classes dummy support
-        '_classobj'     : 'interp_classobj.W_ClassObject',
-        '_instance'     : 'interp_classobj.W_InstanceObject',
-        # default __metaclass__
-        '__metaclass__' : '(space.w_type)',
+        # default __metaclass__: old-style class
+        '__metaclass__' : 'interp_classobj.W_ClassObject',
 
         # interp-level function definitions
         'abs'           : 'operation.abs',

Modified: pypy/dist/pypy/module/__builtin__/operation.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/operation.py	(original)
+++ pypy/dist/pypy/module/__builtin__/operation.py	Sat Jul 12 14:55:43 2008
@@ -181,20 +181,6 @@
 """
     if w_sentinel is None:
         return space.iter(w_collection_or_callable) 
-        # XXX it seems that CPython checks the following 
-        #     for newstyle but doesn't for oldstyle classes :-( 
-        #w_res = space.iter(w_collection_or_callable)
-        #w_typeres = space.type(w_res) 
-        #try: 
-        #    space.getattr(w_typeres, space.wrap('next'))
-        #except OperationError, e: 
-        #    if not e.match(space, space.w_AttributeError): 
-        #        raise 
-        #    raise OperationError(space.w_TypeError, 
-        #        space.wrap("iter() returned non-iterator of type '%s'" % 
-        #                   w_typeres.name))
-        #else: 
-        #    return w_res 
     else:
         return iter_sentinel(space, w_collection_or_callable, w_sentinel)
 

Modified: pypy/dist/pypy/module/__builtin__/test/test_builtin.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_builtin.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_builtin.py	Sat Jul 12 14:55:43 2008
@@ -75,16 +75,16 @@
         def nosp(x): return [y for y in x if y[0]!='_']
         assert f() == []
         assert g() == ['a', 'b', 'c']
-        class X: pass
+        class X(object): pass
         assert nosp(dir(X)) == []
-        class X:
+        class X(object):
             a = 23
             c = 45
             b = 67
         assert nosp(dir(X)) == ['a', 'b', 'c']
 
     def test_dir_in_broken_locals(self):
-        class C:
+        class C(object):
             def __getitem__(self, item):
                 raise KeyError(item)
             def keys(self):
@@ -100,7 +100,7 @@
         assert g() == {'a':0, 'b':0, 'c':0}
 
     def test_getattr(self):
-        class a:
+        class a(object):
             i = 5
         assert getattr(a, 'i') == 5
         raises(AttributeError, getattr, a, 'k')
@@ -282,7 +282,7 @@
 
     def test_reversed_custom_objects(self):
         """make sure __reversed__ is called when defined"""
-        class SomeClass:
+        class SomeClass(object):
             def __reversed__(self):
                 return 42
         obj = SomeClass()
@@ -297,7 +297,7 @@
         assert cmp(u"abc", 12) != 0
 
     def test_cmp_more(self):
-        class C:
+        class C(object):
             def __eq__(self, other):
                 return True
             def __cmp__(self, other):
@@ -332,7 +332,7 @@
         raises(TypeError,coerce, u'a' , 'a')
 
     def test_return_None(self):
-        class X: pass
+        class X(object): pass
         x = X()
         assert setattr(x, 'x', 11) == None
         assert delattr(x, 'x') == None
@@ -343,7 +343,7 @@
         assert divmod(15,10) ==(1,5)
 
     def test_callable(self):
-        class Call:
+        class Call(object):
             def __call__(self, a):
                 return a+2
         assert callable(Call()), (
@@ -351,10 +351,6 @@
         assert callable(int), (
                     "Builtin function 'callable' misreads int")
         class Call:
-            try:
-                __metaclass__ = _classobj
-            except NameError: # not running on PyPy, assuming oldstyle implicitely 
-                pass
             def __call__(self, a):
                 return a+2
         assert callable(Call())
@@ -374,10 +370,7 @@
         assert not callable(a), (
                     "Builtin function 'callable' tricked by instance-__call__")
         class NoCall:
-            try:
-                __metaclass__ = _classobj
-            except NameError: # not running on PyPy, assuming oldstyle implicitely 
-                pass
+            pass
         assert not callable(NoCall())
 
     def test_hash(self):
@@ -435,7 +428,7 @@
         raises(TypeError, issubclass, int, (float, 6))
 
     def test_staticmethod(self):
-        class X:
+        class X(object):
             def f(*args, **kwds): return args, kwds
             f = staticmethod(f)
         assert X.f() == ((), {})
@@ -444,7 +437,7 @@
         assert X().f(42, x=43) == ((42,), {'x': 43})
 
     def test_classmethod(self):
-        class X:
+        class X(object):
             def f(*args, **kwds): return args, kwds
             f = classmethod(f)
         class Y(X):

Modified: pypy/dist/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_classobj.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_classobj.py	Sat Jul 12 14:55:43 2008
@@ -1,8 +1,5 @@
 
 class AppTestOldstyle(object):
-    def setup_class(cls):
-        from pypy.conftest import gettestobjspace
-        cls.space = gettestobjspace(**{"objspace.std.oldstyle": True})
 
     def test_simple(self):
         class A:

Modified: pypy/dist/pypy/module/__builtin__/test/test_descriptor.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_descriptor.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_descriptor.py	Sat Jul 12 14:55:43 2008
@@ -3,7 +3,7 @@
 
 class AppTestBuiltinApp:
     def test_staticmethod(self):
-        class C:
+        class C(object):
             def f(a, b):
                 return a+b
             f = staticmethod(f)
@@ -18,7 +18,7 @@
         assert D.f("abc", "def") == "abcdef"
 
     def test_classmethod(self):
-        class C:
+        class C(object):
             def f(cls, stuff):
                 return cls, stuff
             f = classmethod(f)
@@ -189,7 +189,7 @@
         assert C.__dict__["f"](p) == "B.f->C.f"
 
     def test_super_errors(self):
-        class C:
+        class C(object):
             pass
         class D(C):
             pass
@@ -231,7 +231,7 @@
     def test_property_docstring(self):
         assert property.__doc__.startswith('property')
 
-        class A:
+        class A(object):
             pass
 
         A.x = property(lambda x: x, lambda x, y: x, lambda x:x, 'xxx')

Modified: pypy/dist/pypy/module/__builtin__/test/test_functional.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_functional.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_functional.py	Sat Jul 12 14:55:43 2008
@@ -156,10 +156,10 @@
 
     def test_all(self):
 
-        class TestFailingBool:
+        class TestFailingBool(object):
             def __nonzero__(self):
                 raise RuntimeError
-        class TestFailingIter:
+        class TestFailingIter(object):
             def __iter__(self):
                 raise RuntimeError
 
@@ -178,10 +178,10 @@
 
     def test_any(self):
 
-        class TestFailingBool:
+        class TestFailingBool(object):
             def __nonzero__(self):
                 raise RuntimeError
-        class TestFailingIter:
+        class TestFailingIter(object):
             def __iter__(self):
                 raise RuntimeError
 

Modified: pypy/dist/pypy/module/__builtin__/test/test_reduce.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_reduce.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_reduce.py	Sat Jul 12 14:55:43 2008
@@ -14,7 +14,7 @@
        assert reduce(lambda x, y: x-y, [2, 8], 10) == 0
 
    def test_from_cpython(self):
-      class SequenceClass:
+      class SequenceClass(object):
          def __init__(self, n):
             self.n = n
          def __getitem__(self, i):

Modified: pypy/dist/pypy/module/__builtin__/test/test_vars.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_vars.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_vars.py	Sat Jul 12 14:55:43 2008
@@ -9,7 +9,7 @@
         raises(TypeError, vars,  0, 1)
 
     def test_vars_correct_arguments(self):
-        class a:
+        class a(object):
             def __init__(self):
                 self.res = 42
         assert vars(a) == a.__dict__

Modified: pypy/dist/pypy/module/operator/test/test_operator.py
==============================================================================
--- pypy/dist/pypy/module/operator/test/test_operator.py	(original)
+++ pypy/dist/pypy/module/operator/test/test_operator.py	Sat Jul 12 14:55:43 2008
@@ -6,7 +6,7 @@
 
     def test_getters_are_not_regular_functions(self):
         import operator
-        class A:
+        class A(object):
             getx = operator.attrgetter('x')
             get3 = operator.itemgetter(3)
         a = A()

Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Sat Jul 12 14:55:43 2008
@@ -63,10 +63,6 @@
 
     PACKAGE_PATH = 'objspace.std'
 
-    def setoptions(self, **kwds):
-        if "oldstyle" in kwds:
-            self.config.objspace.std.oldstyle = kwds["oldstyle"]
-
     def initialize(self):
         "NOT_RPYTHON: only for initializing the space."
         self._typecache = Cache()
@@ -314,10 +310,8 @@
         self.make_builtins()
         self.sys.setmodule(w_mod)
 
-        # dummy old-style classes types
-        self.w_classobj = W_TypeObject(self, 'classobj', [self.w_object], {})
-        self.w_instance = W_TypeObject(self, 'instance', [self.w_object], {})
-        self.setup_old_style_classes()
+        # the type of old-style classes
+        self.w_classobj = self.builtin.get('__metaclass__')
 
         # fix up a problem where multimethods apparently don't 
         # like to define this at interp-level 
@@ -336,9 +330,6 @@
         """)
         self.w_dict.__flags__ = old_flags
 
-        if self.config.objspace.std.oldstyle:
-            self.enable_old_style_classes_as_default_metaclass()
-
         # final setup
         self.setup_builtin_modules()
         # Adding transparent proxy call
@@ -351,23 +342,6 @@
             self.setattr(w___pypy__, self.wrap('get_tproxy_controller'),
                           self.wrap(app_proxy_controller))
 
-    def enable_old_style_classes_as_default_metaclass(self):
-        self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
-
-    def enable_new_style_classes_as_default_metaclass(self):
-        space = self
-        try: 
-            self.delitem(self.builtin.w_dict, self.wrap('__metaclass__')) 
-        except OperationError, e: 
-            if not e.match(space, space.w_KeyError): 
-                raise 
-
-    def setup_old_style_classes(self):
-        """NOT_RPYTHON"""
-        # sanity check that this approach is working and is not too late
-        self.w_classobj = self.getattr(self.builtin, self.wrap('_classobj'))
-        self.w_instance = self.getattr(self.builtin, self.wrap('_instance'))
-
     def create_builtin_module(self, pyname, publicname):
         """NOT_RPYTHON
         helper function which returns the wrapped module and its dict.

Modified: pypy/dist/pypy/objspace/std/test/test_complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_complexobject.py	Sat Jul 12 14:55:43 2008
@@ -59,6 +59,8 @@
 
 class AppTestAppComplexTest:
     def setup_class(cls):
+        # XXX these tests probably copied directly from CPython
+        # please port them to pypy style :-/
         cls.w_helper = cls.space.appexec([], """
             ():
                 import sys

Modified: pypy/dist/pypy/objspace/std/test/test_dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_dictobject.py	Sat Jul 12 14:55:43 2008
@@ -314,7 +314,7 @@
         assert str(d) == '{0: {...}}'
 
         # Mutating while repr'ing
-        class Machiavelli:
+        class Machiavelli(object):
             def __repr__(self):
                 d.clear()
                 return "42"

Modified: pypy/dist/pypy/objspace/std/test/test_floatobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_floatobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_floatobject.py	Sat Jul 12 14:55:43 2008
@@ -91,7 +91,7 @@
         assert 0.0 == round(22.22222, -2)
 
     def test_special_float_method(self):
-        class a:
+        class a(object):
             def __float__(self): 
                 self.ar = True 
                 return None
@@ -99,7 +99,7 @@
         raises(TypeError, float, inst) 
         assert inst.ar 
 
-        class b: 
+        class b(object): 
             pass 
         raises((AttributeError, TypeError), float, b()) 
 

Modified: pypy/dist/pypy/objspace/std/test/test_index.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_index.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_index.py	Sat Jul 12 14:55:43 2008
@@ -3,7 +3,7 @@
 
 class AppTest_IndexProtocol:
     def setup_class(self):
-        self.space = gettestobjspace(oldstyle=True)
+        self.space = gettestobjspace()
         w_oldstyle = self.space.appexec([], """():
             class oldstyle:
                 def __index__(self):

Modified: pypy/dist/pypy/objspace/std/test/test_intobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_intobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_intobject.py	Sat Jul 12 14:55:43 2008
@@ -386,7 +386,7 @@
         assert (j(100) >> 2,  type(j(100) >> 2)) == (      25, int)
 
     def test_special_int(self):
-        class a:
+        class a(object):
             def __int__(self): 
                 self.ar = True 
                 return None
@@ -394,12 +394,12 @@
         raises(TypeError, int, inst) 
         assert inst.ar == True 
 
-        class b: 
+        class b(object): 
             pass 
         raises((AttributeError,TypeError), int, b()) 
 
     def test_special_long(self):
-        class a:
+        class a(object):
             def __long__(self): 
                 self.ar = True 
                 return None
@@ -407,7 +407,7 @@
         raises(TypeError, long, inst) 
         assert inst.ar == True 
 
-        class b: 
+        class b(object): 
             pass 
         raises((AttributeError,TypeError), long, b()) 
 

Modified: pypy/dist/pypy/objspace/std/test/test_iterobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_iterobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_iterobject.py	Sat Jul 12 14:55:43 2008
@@ -38,7 +38,7 @@
 
 class AppTestW_IterObjectApp:
     def test_user_iter(self):
-        class C:
+        class C(object):
             def next(self):
                 raise StopIteration
             def __iter__(self):
@@ -46,13 +46,13 @@
         assert list(C()) == []
 
     def test_iter_getitem(self):
-        class C:
+        class C(object):
             def __getitem__(self, i):
                 return range(2)[i]
         assert list(C()) == range(2)
 
     def test_iter_fail_noseq(self):
-        class C:
+        class C(object):
             pass
         raises(TypeError,
                           iter,

Modified: pypy/dist/pypy/objspace/std/test/test_proxy_function.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_proxy_function.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_proxy_function.py	Sat Jul 12 14:55:43 2008
@@ -50,7 +50,7 @@
         def f(self):
             return 3
         
-        class A:
+        class A(object):
             pass
             
         fun = self.get_proxy(f)
@@ -81,18 +81,18 @@
         assert f.__doc__ is None
 
     def test_proxy_bind_method(self):
-        class A:
+        class A(object):
             pass
         
         def f(self):
             return 3
         
-        class AA:
+        class AA(object):
             pass
         
         from __pypy__ import tproxy as proxy
         a = A()
-        class X:
+        class X(object):
             def __init__(self, x):
                 self.x = x
             def f(self, name, *args, **kwargs):

Modified: pypy/dist/pypy/objspace/std/test/test_proxy_internals.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_proxy_internals.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_proxy_internals.py	Sat Jul 12 14:55:43 2008
@@ -129,29 +129,3 @@
             pass
 
         t = tproxy(file, f)
-
-class DONTAppTestProxyType(AppProxy):
-    def test_filetype(self):
-        f = self.get_proxy(file)
-        f("/tmp/sth", "w").write("aaa")
-        assert open("/tmp/sth").read() == "aaa"
-
-    def test_fileobject(self):
-        f = open("/tmp/sth", "w")
-        fp = self.get_proxy(f)
-        fp.write("aaa")
-        fp.close()
-        assert open("/tmp/sth").read() == "aaa"
-
-    def test_isinstance(self):
-        class A:
-            pass
-
-        a = A()
-        Ap = self.get_proxy(A)
-        ap = self.get_proxy(a)
-        assert isinstance(a, A)
-        assert isinstance(a, Ap)
-        assert isinstance(ap, A)
-        assert isinstance(ap, Ap)
-        assert type(a) is type(ap)

Modified: pypy/dist/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_stringobject.py	Sat Jul 12 14:55:43 2008
@@ -509,7 +509,7 @@
     def test_unicode_join_endcase(self):
         # This class inserts a Unicode object into its argument's natural
         # iteration, in the 3rd position.
-        class OhPhooey:
+        class OhPhooey(object):
             def __init__(self, seq):
                 self.it = iter(seq)
                 self.i = 0

Modified: pypy/dist/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_typeobject.py	Sat Jul 12 14:55:43 2008
@@ -215,15 +215,9 @@
             assert 0, "shouldn't be able to create inheritance cycles"
 
         # let's throw a classic class into the mix:
-        try:
-            class Classic:
-                __metaclass__ = _classobj
-                def meth2(self):
-                    return 3
-        except NameError:
-            class Classic:
-                def meth2(self):
-                    return 3
+        class Classic:
+            def meth2(self):
+                return 3
 
         D.__bases__ = (C, Classic)
 
@@ -369,27 +363,14 @@
         assert type(HasInnerMetaclass) == HasInnerMetaclass.__metaclass__
 
     def test_implicit_metaclass(self):
-        global __metaclass__
-        try:
-            old_metaclass = __metaclass__
-            has_old_metaclass = True
-        except NameError:
-            has_old_metaclass = False
-            
         class __metaclass__(type):
             pass
 
-        class HasImplicitMetaclass:
-            pass
-
-        try:
-            assert type(HasImplicitMetaclass) == __metaclass__
-        finally:
-            if has_old_metaclass:
-                __metaclass__ = old_metaclass
-            else:
-                del __metaclass__
+        g = {'__metaclass__': __metaclass__}
+        exec "class HasImplicitMetaclass: pass\n" in g
 
+        HasImplicitMetaclass = g['HasImplicitMetaclass']
+        assert type(HasImplicitMetaclass) == __metaclass__
 
     def test_mro(self):
         class A_mro(object):
@@ -410,8 +391,8 @@
         assert getattr(B_mro(), 'a', None) == None
 
     def test_abstract_mro(self):
-        class A1:
-            __metaclass__ = _classobj
+        class A1:    # old-style class
+            pass
         class B1(A1):
             pass
         class C1(A1):
@@ -595,7 +576,7 @@
 
     def test_only_classic_bases_fails(self):
         class C:
-            __metaclass__ = _classobj
+            pass
         raises(TypeError, type, 'D', (C,), {})
 
     def test_set___class__(self):

Modified: pypy/dist/pypy/objspace/std/test/test_unicodeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_unicodeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_unicodeobject.py	Sat Jul 12 14:55:43 2008
@@ -269,17 +269,10 @@
         assert U(u'test').__class__ is U
 
     def test_call_unicode(self):
-        skip("does not work")
-        class X:
+        class X(object):
             def __unicode__(self):
                 return u'x'
-
-        try:
-            unicode(X(), 'ascii')
-        except TypeError, t:
-            assert 'need string or buffer' in str(t)
-        else:
-            raise Exception("DID NOT RAISE")
+        raises(TypeError, unicode, X(), 'ascii')
 
     def test_startswith(self):
         assert u'ab'.startswith(u'ab') is True

Modified: pypy/dist/pypy/objspace/std/test/test_userobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_userobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_userobject.py	Sat Jul 12 14:55:43 2008
@@ -8,21 +8,21 @@
         cls.space = conftest.gettestobjspace(**cls.OPTIONS)
 
     def test_emptyclass(self):
-        class empty: pass
+        class empty(object): pass
         inst = empty()
         assert isinstance(inst, empty)
-        inst.attr=23
-        assert inst.attr ==23
+        inst.attr = 23
+        assert inst.attr == 23
 
     def test_method(self):
-        class A:
+        class A(object):
             def f(self, v):
                 return v*42
         a = A()
         assert a.f('?') == '??????????????????????????????????????????'
 
     def test_unboundmethod(self):
-        class A:
+        class A(object):
             def f(self, v):
                 return v*17
         a = A()
@@ -46,7 +46,7 @@
         assert len(result) ==3
 
     def test_subsubclass(self):
-        class base:
+        class base(object):
             baseattr = 12
         class derived(base):
             derivedattr = 34
@@ -56,7 +56,7 @@
         assert inst.derivedattr ==34
 
     def test_descr_get(self):
-        class C:
+        class C(object):
             class desc(object):
                 def __get__(self, ob, cls=None):
                     return 42
@@ -86,21 +86,21 @@
         assert c.wibble == 22
 
     def test_class_setattr(self):
-        class C:
+        class C(object):
             pass
         C.a = 1
         assert hasattr(C, 'a')
         assert C.a == 1
 
     def test_add(self):
-        class C:
+        class C(object):
             def __add__(self, other):
                 return self, other
         c1 = C()
         assert c1+3 == (c1, 3)
 
     def test_call(self):
-        class C:
+        class C(object):
             def __call__(self, *args):
                 return args
         c1 = C()
@@ -118,7 +118,7 @@
         assert c1.a == '->a'
 
     def test_getattr(self):
-        class C:
+        class C(object):
             def __getattr__(self, name):
                 return '->' + name
         c1 = C()
@@ -207,12 +207,6 @@
         s = repr(Foo())
         assert s.startswith('<a.b.c.Foo object at ')
 
-    def test_obscure(self):
-        skip("Too obscure")
-        class Foo(object):
-            locals()[42] = 98
-        # assert did not crash
-
 class AppTestWithMultiMethodVersion2(AppTestUserObject):
     OPTIONS = {}    # for test_builtinshortcut.py
 

Modified: pypy/dist/pypy/objspace/test/test_descriptor.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_descriptor.py	(original)
+++ pypy/dist/pypy/objspace/test/test_descriptor.py	Sat Jul 12 14:55:43 2008
@@ -32,7 +32,7 @@
         raises(AttributeError, X.v.__delete__, x)
 
     def test_special_methods_returning_strings(self): 
-        class A: 
+        class A(object): 
             seen = []
             def __str__(self): 
                 self.seen.append(1) 
@@ -50,24 +50,25 @@
         raises(TypeError, hex, inst) 
         assert A.seen == [1,2,3,4]
 
-class TestDesciprtorOnStd: 
     def test_hash(self): 
-        class A:
+        class A(object):
             pass 
         hash(A()) 
-        class B: 
+
+        # as in CPython, for new-style classes we don't check if
+        # __eq__ is overridden without __hash__ being overridden,
+        # and so hash(B()) always just works (but gives a slightly
+        # useless result).
+        class B(object):
             def __eq__(self, other): pass 
-        raises(TypeError, hash, B()) 
-        class C: 
-            def __cmp__(self, other): pass 
-        raises(TypeError, "hash(C())")
+        hash(B())
 
-        #class D: 
-        #    def __hash__(self): 
-        #        return 23L
-        #raises(TypeError, hash, D())
+        # same as above for __cmp__
+        class C(object):
+            def __cmp__(self, other): pass 
+        hash(C())
 
-        class E: 
+        class E(object):
             def __hash__(self): 
                 return "something"
         raises(TypeError, hash, E())

Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py	(original)
+++ pypy/dist/pypy/translator/goal/app_main.py	Sat Jul 12 14:55:43 2008
@@ -10,8 +10,6 @@
   -u             unbuffered binary stdout and stderr
   -h, --help     show this help message and exit
   -m             library module to be run as a script (terminates option list)
-  -k, --oldstyle use old-style classes instead of newstyle classes
-                 everywhere %(oldstyle)s
   --version      print the PyPy version
   --info         print translation information about this PyPy executable
 """
@@ -123,10 +121,7 @@
 
 def print_help():
     print 'usage: %s [options]' % (sys.executable,)
-    details = {'oldstyle': ''}
-    if sys.pypy_translation_info['objspace.std.oldstyle']:
-        details['oldstyle'] = '[default]'
-    print __doc__ % details
+    print __doc__
 
 def print_error(msg):
     print >> sys.stderr, msg
@@ -221,7 +216,6 @@
     i = 0
     run_module = False
     run_stdin = False
-    oldstyle_classes = False
     unbuffered = False
     while i < len(argv):
         arg = argv[i]
@@ -260,8 +254,6 @@
                 return 2
             run_module = True
             break
-        elif arg in ('-k', '--oldstyle'):
-            oldstyle_classes = True
         elif arg == '--':
             i += 1
             break     # terminates option list
@@ -287,10 +279,6 @@
     mainmodule = type(sys)('__main__')
     sys.modules['__main__'] = mainmodule
 
-    if oldstyle_classes:
-        import __builtin__
-        __builtin__.__metaclass__ = __builtin__._classobj
-
     if import_site:
         try:
             import site



More information about the Pypy-commit mailing list