Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3k Changeset: r86174:b00718188b59 Date: 2016-08-12 17:35 +0100 http://bitbucket.org/pypy/pypy/changeset/b00718188b59/
Log: Remove code added by py2-specific branch 'resource_warning' 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/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) -@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() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit