[pypy-svn] r79815 - in pypy/branch/remove-sys-recursionlimit/pypy: interpreter module/_stackless module/sys
fijal at codespeak.net
fijal at codespeak.net
Sat Dec 4 16:13:57 CET 2010
Author: fijal
Date: Sat Dec 4 16:13:55 2010
New Revision: 79815
Modified:
pypy/branch/remove-sys-recursionlimit/pypy/interpreter/executioncontext.py
pypy/branch/remove-sys-recursionlimit/pypy/module/_stackless/interp_coroutine.py
pypy/branch/remove-sys-recursionlimit/pypy/module/sys/vm.py
Log:
remove tracking of recursion depth. issue a deprecation warning when calling
sys.setrecursionlimit
Modified: pypy/branch/remove-sys-recursionlimit/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/remove-sys-recursionlimit/pypy/interpreter/executioncontext.py (original)
+++ pypy/branch/remove-sys-recursionlimit/pypy/interpreter/executioncontext.py Sat Dec 4 16:13:55 2010
@@ -27,7 +27,6 @@
def __init__(self, space):
self.space = space
self.topframeref = jit.vref_None
- self.framestackdepth = 0
# tracing: space.frame_trace_action.fire() must be called to ensure
# that tracing occurs whenever self.w_tracefunc or self.is_tracing
# is modified.
@@ -54,9 +53,6 @@
return frame
def enter(self, frame):
- if self.framestackdepth > self.space.sys.recursionlimit:
- raise self.space.prebuilt_recursion_error
- self.framestackdepth += 1
frame.f_backref = self.topframeref
self.topframeref = jit.virtual_ref(frame)
@@ -66,7 +62,6 @@
self._trace(frame, 'leaveframe', self.space.w_None)
finally:
self.topframeref = frame.f_backref
- self.framestackdepth -= 1
jit.virtual_ref_finish(frame)
if self.w_tracefunc is not None and not frame.hide():
@@ -80,7 +75,6 @@
def __init__(self):
self.topframe = None
- self.framestackdepth = 0
self.w_tracefunc = None
self.profilefunc = None
self.w_profilefuncarg = None
@@ -88,7 +82,6 @@
def enter(self, ec):
ec.topframeref = jit.non_virtual_ref(self.topframe)
- ec.framestackdepth = self.framestackdepth
ec.w_tracefunc = self.w_tracefunc
ec.profilefunc = self.profilefunc
ec.w_profilefuncarg = self.w_profilefuncarg
@@ -97,7 +90,6 @@
def leave(self, ec):
self.topframe = ec.gettopframe()
- self.framestackdepth = ec.framestackdepth
self.w_tracefunc = ec.w_tracefunc
self.profilefunc = ec.profilefunc
self.w_profilefuncarg = ec.w_profilefuncarg
@@ -105,7 +97,6 @@
def clear_framestack(self):
self.topframe = None
- self.framestackdepth = 0
# the following interface is for pickling and unpickling
def getstate(self, space):
@@ -121,17 +112,14 @@
self.topframe = space.interp_w(PyFrame, frames_w[-1])
else:
self.topframe = None
- self.framestackdepth = len(frames_w)
def getframestack(self):
- index = self.framestackdepth
- lst = [None] * index
+ lst = []
f = self.topframe
- while index > 0:
- index -= 1
- lst[index] = f
+ while f is not None:
+ lst.append(f)
f = f.f_backref()
- assert f is None
+ lst.reverse()
return lst
# coroutine: I think this is all, folks!
Modified: pypy/branch/remove-sys-recursionlimit/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/branch/remove-sys-recursionlimit/pypy/module/_stackless/interp_coroutine.py (original)
+++ pypy/branch/remove-sys-recursionlimit/pypy/module/_stackless/interp_coroutine.py Sat Dec 4 16:13:55 2010
@@ -304,16 +304,14 @@
def w_descr__framestack(space, self):
assert isinstance(self, AppCoroutine)
- index = self.subctx.framestackdepth
- if not index:
- return space.newtuple([])
- items = [None] * index
f = self.subctx.topframe
- while index > 0:
- index -= 1
- items[index] = space.wrap(f)
+ items = []
+ if not f:
+ return space.newtuple([])
+ while f is not None:
+ items.append(space.wrap(f))
f = f.f_backref()
- assert f is None
+ items.reverse()
return space.newtuple(items)
def makeStaticMethod(module, classname, funcname):
Modified: pypy/branch/remove-sys-recursionlimit/pypy/module/sys/vm.py
==============================================================================
--- pypy/branch/remove-sys-recursionlimit/pypy/module/sys/vm.py (original)
+++ pypy/branch/remove-sys-recursionlimit/pypy/module/sys/vm.py Sat Dec 4 16:13:55 2010
@@ -41,27 +41,21 @@
f = ec.getnextframe_nohidden(f)
return space.wrap(f)
-# directly from the C code in ceval.c, might be moved somewhere else.
-
def setrecursionlimit(space, w_new_limit):
- """Set the maximum depth of the Python interpreter stack to n. This
-limit prevents infinite recursion from causing an overflow of the C
-stack and crashing Python. The highest possible limit is platform
-dependent."""
+ """DEPRECATED on PyPy. Will issue warning and not work
+ """
new_limit = space.int_w(w_new_limit)
if new_limit <= 0:
raise OperationError(space.w_ValueError,
space.wrap("recursion limit must be positive"))
# global recursion_limit
# we need to do it without writing globals.
+ space.warn('setrecursionlimit deprecated', space.w_DeprecationWarning)
space.sys.recursionlimit = new_limit
def getrecursionlimit(space):
- """Return the current value of the recursion limit, the maximum depth
- of the Python interpreter stack. This limit prevents infinite
- recursion from causing an overflow of the C stack and crashing Python.
+ """DEPRECATED on PyPy. Will issue warning and not work
"""
-
return space.wrap(space.sys.recursionlimit)
def setcheckinterval(space, interval):
More information about the Pypy-commit
mailing list