[pypy-svn] r26659 - in pypy/dist/pypy: interpreter module/__builtin__ objspace objspace/std objspace/test

pedronis at codespeak.net pedronis at codespeak.net
Tue May 2 13:56:11 CEST 2006


Author: pedronis
Date: Tue May  2 13:56:09 2006
New Revision: 26659

Modified:
   pypy/dist/pypy/interpreter/baseobjspace.py
   pypy/dist/pypy/interpreter/mixedmodule.py
   pypy/dist/pypy/module/__builtin__/operation.py
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/std/objspace.py
   pypy/dist/pypy/objspace/test/test_descroperation.py
Log:
make test_builtin pass again. Make intern behavior more similar to CPython, also discovered that setattr
doesn't anymore force attribute names to be string in 2.4 .



Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py	Tue May  2 13:56:09 2006
@@ -385,6 +385,15 @@
         else:
             return self.w_False
 
+    def new_interned_w_str(self, w_s):
+        s = self.str_w(w_s)
+        try:
+            return self.interned_strings[s]
+        except KeyError:
+            pass
+        self.interned_strings[s] = w_s
+        return w_s
+
     def new_interned_str(self, s):
         try:
             return self.interned_strings[s]

Modified: pypy/dist/pypy/interpreter/mixedmodule.py
==============================================================================
--- pypy/dist/pypy/interpreter/mixedmodule.py	(original)
+++ pypy/dist/pypy/interpreter/mixedmodule.py	Tue May  2 13:56:09 2006
@@ -34,7 +34,7 @@
         w_value = space.finditem(self.w_dict, w_name)
         if self.lazy and w_value is None:
             name = space.str_w(w_name)
-            w_name = space.new_interned_str(name)
+            w_name = space.new_interned_w_str(w_name)
             try: 
                 loader = self.loaders[name]
             except KeyError: 

Modified: pypy/dist/pypy/module/__builtin__/operation.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/operation.py	(original)
+++ pypy/dist/pypy/module/__builtin__/operation.py	Tue May  2 13:56:09 2006
@@ -162,7 +162,7 @@
 
 def intern(space, w_str):
     if space.is_w(space.type(w_str), space.w_str):
-        return space.new_interned_str(space.str_w(w_str))
+        return space.new_interned_w_str(w_str)
     raise OperationError(space.w_TypeError, space.wrap("intern() argument 1 must be string."))
 
 def callable(space, w_object):

Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Tue May  2 13:56:09 2006
@@ -36,9 +36,6 @@
                 return
         w_dict = w_obj.getdict()
         if w_dict is not None:
-            # note: don't use w_name as a key in w_dict directly -- the expected
-            # result of setattr() is that it never stores subclasses of 'str'
-            # in the __dict__
             space.set_str_keyed_item(w_dict, w_name, w_value)
             return
         raiseattrerror(space, w_obj, name, w_descr)

Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Tue May  2 13:56:09 2006
@@ -453,8 +453,6 @@
 
     def set_str_keyed_item(self, w_obj, w_key, w_value):
         # performance shortcut to avoid creating the OperationError(KeyError)
-        if type(w_key) is not W_StringObject:
-            w_key = self.new_interned_str(self.str_w(w_key))
         if type(w_obj) is W_DictObject:
             w_obj.content[w_key] = w_value
         else:

Modified: pypy/dist/pypy/objspace/test/test_descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_descroperation.py	(original)
+++ pypy/dist/pypy/objspace/test/test_descroperation.py	Tue May  2 13:56:09 2006
@@ -189,8 +189,10 @@
         s = S("abc")
         setattr(s, s, s)
         assert len(s.__dict__) == 1
-        assert type(s.__dict__.keys()[0]) is str   # don't store S keys
-        assert s.abc is s
+        # this behavior changed in 2.4
+        #assert type(s.__dict__.keys()[0]) is str   # don't store S keys
+        #assert s.abc is s
+        getattr(s,s) is s
 
     def test_notimplemented(self):
         #import types



More information about the Pypy-commit mailing list