[pypy-commit] pypy default: remove 'space.w_str'

arigo pypy.commits at gmail.com
Wed Feb 22 10:12:55 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r90303:f325422fa569
Date: 2017-02-22 16:12 +0100
http://bitbucket.org/pypy/pypy/changeset/f325422fa569/

Log:	remove 'space.w_str'

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -45,7 +45,6 @@
 
     def str_w(self, space):
         return NonConstant("foobar")
-    identifier_w = bytes_w = str_w
 
     def unicode_w(self, space):
         return NonConstant(u"foobar")
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -89,12 +89,15 @@
         for typedef, cls in builtin_type_classes.items():
             w_type = self.gettypeobject(typedef)
             self.builtin_types[typedef.name] = w_type
-            if 1: # typedef.name != "str":      BACKCOMPAT
-                setattr(self, 'w_' + typedef.name, w_type)
-            if typedef.name == "str":
-                self.w_bytes = w_type
+            name = typedef.name
+            # we don't expose 'space.w_str' at all, to avoid confusion
+            # with Python 3.  Instead, in Python 2, it becomes
+            # space.w_bytes (or space.w_text).
+            if name == 'str':
+                name = 'bytes'
+            setattr(self, 'w_' + name, w_type)
             self._interplevel_classes[w_type] = cls
-        self.w_text = self.w_bytes # this is w_unicode on Py3
+        self.w_text = self.w_bytes   # 'space.w_text' is w_unicode on Py3
         self.w_dict.flag_map_or_seq = 'M'
         self.builtin_types["NotImplemented"] = self.w_NotImplemented
         self.builtin_types["Ellipsis"] = self.w_Ellipsis


More information about the pypy-commit mailing list