[pypy-commit] pypy py3.5: Merge with py3k

raffael_t pypy.commits at gmail.com
Mon Aug 15 06:17:37 EDT 2016


Author: Raffael Tfirst <raffael.tfirst at gmail.com>
Branch: py3.5
Changeset: r86196:360908aa059a
Date: 2016-08-15 12:16 +0200
http://bitbucket.org/pypy/pypy/changeset/360908aa059a/

Log:	Merge with py3k

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1801,40 +1801,6 @@
             _warnings.warn(msg, warningcls, stacklevel=stacklevel)
         """)
 
-    def resource_warning(self, w_msg, w_tb):
-        self.appexec([w_msg, w_tb],
-                     """(msg, tb):
-            import sys
-            print >> sys.stderr, msg
-            if tb:
-                print >> sys.stderr, "Created at (most recent call last):"
-                print >> sys.stderr, tb
-        """)
-
-    def format_traceback(self):
-        # we need to disable track_resources before calling the traceback
-        # module. Else, it tries to open more files to format the traceback,
-        # the file constructor will call space.format_traceback etc., in an
-        # inifite recursion
-        flag = self.sys.track_resources
-        self.sys.track_resources = False
-        try:
-            return self.appexec([],
-                         """():
-                import sys, traceback
-                # the "1" is because we don't want to show THIS code
-                # object in the traceback
-                try:
-                    f = sys._getframe(1)
-                except ValueError:
-                    # this happens if you call format_traceback at the very beginning
-                    # of startup, when there is no bottom code object
-                    return '<no stacktrace available>'
-                return "".join(traceback.format_stack(f))
-            """)
-        finally:
-            self.sys.track_resources = flag
-
 
 class AppExecCache(SpaceCache):
     def build(cache, source):
diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -209,14 +209,6 @@
         self.check(['-c', 'pass'], {'PYTHONNOUSERSITE': '1'}, sys_argv=['-c'],
                    run_command='pass', **expected)
 
-    def test_track_resources(self, monkeypatch):
-        myflag = [False]
-        def pypy_set_track_resources(flag):
-            myflag[0] = flag
-        monkeypatch.setattr(sys, 'pypy_set_track_resources', pypy_set_track_resources, raising=False)
-        self.check(['-X', 'track-resources'], {}, sys_argv=[''], run_stdin=True)
-        assert myflag[0] == True
-
 class TestInteraction:
     """
     These tests require pexpect (UNIX-only).
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -134,7 +134,7 @@
         assert self.space.lookup(w_instance, "gobbledygook") is None
         w_instance = self.space.appexec([], """():
             class Lookup(object):
-                "bla" 
+                "bla"
             return Lookup()""")
         assert self.space.str_w(self.space.lookup(w_instance, "__doc__")) == "bla"
 
@@ -148,7 +148,7 @@
         assert is_callable(w_func)
         w_lambda_func = self.space.appexec([], "(): return lambda: True")
         assert is_callable(w_lambda_func)
-        
+
         w_instance = self.space.appexec([], """():
             class Call(object):
                 def __call__(self): pass
@@ -308,7 +308,7 @@
 
     def test_call_obj_args(self):
         from pypy.interpreter.argument import Arguments
-        
+
         space = self.space
 
         w_f = space.appexec([], """():
@@ -333,7 +333,7 @@
         assert w_x is w_9
         assert w_y is w_1
 
-        w_res = space.call_obj_args(w_a, w_9, Arguments(space, []))        
+        w_res = space.call_obj_args(w_a, w_9, Arguments(space, []))
         assert w_res is w_9
 
     def test_compare_by_iteration(self):
@@ -383,7 +383,7 @@
         assert not space.isabstractmethod_w(space.getattr(w_B, space.wrap('g')))
         assert not space.isabstractmethod_w(space.getattr(w_B, space.wrap('h')))
 
-class TestModuleMinimal: 
+class TestModuleMinimal:
     def test_sys_exists(self):
         assert self.space.sys
 
@@ -458,28 +458,3 @@
         space.finish()
         # assert that we reach this point without getting interrupted
         # by the OperationError(NameError)
-
-    def test_format_traceback(self):
-        from pypy.tool.pytest.objspace import maketestobjspace
-        from pypy.interpreter.gateway import interp2app
-        #
-        def format_traceback(space):
-            return space.format_traceback()
-        #
-        space = maketestobjspace()
-        w_format_traceback = space.wrap(interp2app(format_traceback))
-        w_tb = space.appexec([w_format_traceback], """(format_traceback):
-            def foo():
-                return bar()
-            def bar():
-                return format_traceback()
-            return foo()
-        """)
-        tb = space.str_w(w_tb)
-        expected = '\n'.join([
-            '  File "?", line 6, in anonymous',  # this is the appexec code object
-            '  File "?", line 3, in foo',
-            '  File "?", line 5, in bar',
-            ''
-        ])
-        assert tb == expected
diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -267,7 +267,7 @@
         space = self.space
         if self.accept_str and space.isinstance_w(w_init, space.w_str):
             # special case to optimize strings passed to a "char *" argument
-            value = w_init.str_w(space)
+            value = space.bytes_w(w_init)
             keepalives[i] = value
             buf, buf_flag = rffi.get_nonmovingbuffer_final_null(value)
             rffi.cast(rffi.CCHARPP, cdata)[0] = buf
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -49,8 +49,6 @@
         '_current_frames'       : 'currentframes._current_frames',
         'setrecursionlimit'     : 'vm.setrecursionlimit',
         'getrecursionlimit'     : 'vm.getrecursionlimit',
-        'pypy_set_track_resources' : 'vm.set_track_resources',
-        'pypy_get_track_resources' : 'vm.get_track_resources',
         'setcheckinterval'      : 'vm.setcheckinterval',
         'getcheckinterval'      : 'vm.getcheckinterval',
         'exc_info'              : 'vm.exc_info',
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -61,13 +61,6 @@
     """
     return space.wrap(space.sys.recursionlimit)
 
- at unwrap_spec(flag=bool)
-def set_track_resources(space, flag):
-    space.sys.track_resources = flag
-
-def get_track_resources(space):
-    return space.wrap(space.sys.track_resources)
-
 @unwrap_spec(interval=int)
 def setcheckinterval(space, interval):
     """Tell the Python interpreter to check for asynchronous events every
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
@@ -434,5 +434,4 @@
 FakeObjSpace.sys.filesystemencoding = 'foobar'
 FakeObjSpace.sys.defaultencoding = 'ascii'
 FakeObjSpace.sys.dlopenflags = 123
-FakeObjSpace.sys.track_resources = False
 FakeObjSpace.builtin = FakeModule()
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -1288,8 +1288,9 @@
     cycle.append(candidate)
     cycle.reverse()
     names = [cls.getname(space) for cls in cycle]
-    raise oefmt(space.w_TypeError,
-                "cycle among base classes: %s", ' < '.join(names))
+    # Can't use oefmt() here, since names is a list of unicodes
+    raise OperationError(space.w_TypeError, space.newunicode(
+        u"cycle among base classes: " + u' < '.join(names)))
 
 
 class TypeCache(SpaceCache):


More information about the pypy-commit mailing list