Author: Armin Rigo <[email protected]>
Branch: py3.5-newtext
Changeset: r90153:c9c2a8f5f76b
Date: 2017-02-15 14:31 +0100
http://bitbucket.org/pypy/pypy/changeset/c9c2a8f5f76b/

Log:    hg merge space-newtext (yay)

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1571,7 +1571,7 @@
     def text_or_None_w(self, w_obj):
         return None if self.is_none(w_obj) else self.text_w(w_obj)
 
-    @not_rpython
+    #@not_rpython    BACKCOMPAT: should be replaced with bytes_w or text_w
     def str_w(self, w_obj):
         """
         if w_obj is unicode, call text_w() (i.e., return the UTF-8-nosg
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -1129,6 +1129,8 @@
             assert space._code_of_sys_exc_info is None
             space._code_of_sys_exc_info = code
         #
+        if hasattr(space, '_see_interp2app'):
+            space._see_interp2app(gateway)      # only for fake/objspace.py
         return fn
 
 
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -359,6 +359,11 @@
         raise oefmt(space.w_AttributeError,
                     "generic property has no __objclass__")
 
+    def spacebind(self, space):
+        if hasattr(space, '_see_getsetproperty'):
+            space._see_getsetproperty(self)      # only for fake/objspace.py
+        return self
+
 
 def interp_attrproperty(name, cls, doc=None, wrapfn=None):
     "NOT_RPYTHON: initialization-time only"
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py 
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -188,7 +188,6 @@
             guard_no_exception(descr=...)
             p95 = call_r(..., descr=<Callr . r EF=5>)     # ll_build
             guard_no_exception(descr=...)
-            guard_nonnull(p95, descr=...)
             i96 = strlen(p95)
             i97 = int_add_ovf(i71, i96)
             guard_no_overflow(descr=...)
@@ -273,7 +272,6 @@
         guard_not_invalidated(descr=...)
         p53 = call_r(ConstClass(fast_str_decode_ascii), p80, descr=<Callr . r 
EF=4>)
         guard_no_exception(descr=...)
-        guard_nonnull(p53, descr=...)
         --TICK--
         jump(..., descr=...)
         """)
diff --git a/pypy/module/struct/test/test_struct.py 
b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -264,6 +264,7 @@
         assert pack(">?", False) == b'\x00'
         assert pack("@?", True) == b'\x01'
         assert pack("@?", False) == b'\x00'
+        assert self.struct.unpack("?", 'X')[0] is True
 
     def test_transitiveness(self):
         c = b'a'
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
@@ -58,7 +58,10 @@
 
     def bigint_w(self, space, allow_conversion=True):
         from rpython.rlib.rbigint import rbigint
-        return rbigint.fromint(NonConstant(42))
+        x = 42
+        if we_are_translated():
+            x = NonConstant(x)
+        return rbigint.fromint(x)
 
 class W_MyListObj(W_MyObject):
     def append(self, w_other):
@@ -123,6 +126,9 @@
                  'unicode', 'complex', 'slice', 'bool', 'text', 'object',
                  'set', 'frozenset', 'bytearray', 'memoryview']
 
+INTERP_TYPES = ['function', 'builtin_function', 'module', 'getset_descriptor',
+                'instance', 'classobj']
+
 class FakeObjSpace(ObjSpace):
     is_fake_objspace = True
 
@@ -220,10 +226,8 @@
     @not_rpython
     def wrap(self, x):
         if not we_are_translated():
-            if isinstance(x, gateway.interp2app):
-                self._see_interp2app(x)
-            if isinstance(x, GetSetProperty):
-                self._see_getsetproperty(x)
+            if isinstance(x, W_Root):
+                x.spacebind(self)
         if isinstance(x, r_singlefloat):
             self._wrap_not_rpython(x)
         if isinstance(x, list):
@@ -234,6 +238,7 @@
 
     @not_rpython
     def _see_interp2app(self, interp2app):
+        """Called by GatewayCache.build()"""
         activation = interp2app._code.activation
         def check():
             scope_w = [w_some_obj()] * NonConstant(42)
@@ -244,6 +249,7 @@
 
     @not_rpython
     def _see_getsetproperty(self, getsetproperty):
+        """Called by GetSetProperty.spacebind()"""
         space = self
         def checkprop():
             getsetproperty.fget(getsetproperty, space, w_some_obj())
@@ -376,6 +382,7 @@
         ann = t.buildannotator()
         def _do_startup():
             self.threadlocals.enter_thread(self)
+            W_SliceObject(w_some_obj(), w_some_obj(), w_some_obj())
         ann.build_types(_do_startup, [], complete_now=False)
         if func is not None:
             ann.build_types(func, argtypes, complete_now=False)
@@ -436,7 +443,9 @@
 @specialize.memo()
 def see_typedef(space, typedef):
     assert isinstance(typedef, TypeDef)
-    if typedef.name not in BUILTIN_TYPES:
+    if typedef.name not in BUILTIN_TYPES and typedef.name not in INTERP_TYPES:
+        print
+        print '------ seeing typedef %r ------' % (typedef.name,)
         for name, value in typedef.rawdict.items():
             space.wrap(value)
 
diff --git a/pypy/objspace/fake/test/test_checkmodule.py 
b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -19,7 +19,7 @@
     space = FakeObjSpace()
     assert len(space._seen_extras) == 1
     assert len(check) == 0
-    space.wrap(interp2app(lambda space: see()))
+    interp2app(lambda space: see()).spacebind(space)
     assert len(space._seen_extras) == 2
     assert len(check) == 0
     space.translates()
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
@@ -135,6 +135,11 @@
         assert typedef is not None
         return self.fromcache(TypeCache).getorbuild(typedef)
 
+    # BACKCOMPAT: this function is still accepted for backward
+    # compatibility, but its usage should be progressively removed
+    # everywhere apart from tests.
+    #@not_rpython # only for tests
+    @specialize.argtype(1)
     def wrap(self, x):
         """ Wraps the Python value 'x' into one of the wrapper classes. This
         should only be used for tests, in real code you need to use the
@@ -183,6 +188,12 @@
         if is_valid_int(x):
             return self.newint(x)
 
+        return self._wrap_not_rpython(x)
+
+    def _wrap_not_rpython(self, x):
+        "NOT_RPYTHON"
+        # _____ this code is here to support testing only _____
+
         # wrap() of a container works on CPython, but the code is
         # not RPython.  Don't use -- it is kept around mostly for tests.
         # Use instead newdict(), newlist(), newtuple().
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -74,6 +74,7 @@
         for name in ('int', 'long', 'str', 'unicode', 'list', 'None', 
'ValueError',
                 'OverflowError'):
             setattr(self, 'w_' + name, eval(name))
+        self.w_bytes = bytes
         import __builtin__ as __builtin__
         self.builtin = __builtin__
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to