[pypy-svn] r9302 - in pypy/branch/dist-interpapp/pypy: module/builtin objspace/std

hpk at codespeak.net hpk at codespeak.net
Fri Feb 18 11:56:37 CET 2005


Author: hpk
Date: Fri Feb 18 11:56:37 2005
New Revision: 9302

Modified:
   pypy/branch/dist-interpapp/pypy/module/builtin/app_descriptor.py
   pypy/branch/dist-interpapp/pypy/objspace/std/objspace.py
Log:
move the "dict.fromkeys" special case out of builtins to 
the standard objectspace 



Modified: pypy/branch/dist-interpapp/pypy/module/builtin/app_descriptor.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/module/builtin/app_descriptor.py	(original)
+++ pypy/branch/dist-interpapp/pypy/module/builtin/app_descriptor.py	Fri Feb 18 11:56:37 2005
@@ -53,21 +53,6 @@
             return self.f(klass, *args, **kwargs)
         return newfunc
 
-if not hasattr(dict, 'fromkeys'):
-    def _fromkeys(cls, seq, value=None):
-        r = cls()
-        for s in seq:
-            r[s] = value
-        return r
-
-    try:
-        dict.fromkeys = classmethod(_fromkeys)
-    except TypeError:
-        pass   # Python2.2 with trivial object space
-
-    del _fromkeys
-
-
 # super is a modified version from Guido's tutorial
 #     http://www.python.org/2.2.3/descrintro.html
 # it exposes the same special attributes as CPython's.

Modified: pypy/branch/dist-interpapp/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/dist-interpapp/pypy/objspace/std/objspace.py	Fri Feb 18 11:56:37 2005
@@ -74,6 +74,17 @@
         self.w_classobj = W_TypeObject(self, 'classobj', [self.w_object], {})
         self.w_instance = W_TypeObject(self, 'instance', [self.w_object], {})
 
+        # fix up a problem where multimethods apparently don't 
+        # like to define this at interp-level 
+        self.appexec([self.w_dict], """
+            (dict): 
+                def fromkeys(cls, seq, value=None):
+                    r = cls()
+                    for s in seq:
+                        r[s] = value
+                    return r
+                dict.fromkeys = classmethod(fromkeys)
+        """) 
         # old-style classes
         #self.setup_old_style_classes()
 



More information about the Pypy-commit mailing list