[pypy-svn] r8591 - in pypy/dist/pypy: interpreter module
pedronis at codespeak.net
pedronis at codespeak.net
Wed Jan 26 10:45:05 CET 2005
Author: pedronis
Date: Wed Jan 26 10:45:04 2005
New Revision: 8591
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/executioncontext.py
pypy/dist/pypy/module/sysinterp.py
Log:
check for recursion limit
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Wed Jan 26 10:45:04 2005
@@ -34,6 +34,8 @@
def __init__(self):
"NOT_RPYTHON: Basic initialization of objects."
self._gatewaycache = Cache()
+ # set recursion limit
+ self.recursion_limit = 1000
# sets all the internal descriptors
self.initialize()
Modified: pypy/dist/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/dist/pypy/interpreter/executioncontext.py (original)
+++ pypy/dist/pypy/interpreter/executioncontext.py Wed Jan 26 10:45:04 2005
@@ -10,6 +10,9 @@
self.framestack = Stack()
def enter(self, frame):
+ if self.framestack.depth() > self.space.recursion_limit:
+ raise OperationError(self.space.w_RuntimeError,
+ self.space.wrap("maximum recursion depth exceeded"))
locals = getthreadlocals()
previous_ec = locals.executioncontext
locals.executioncontext = self
Modified: pypy/dist/pypy/module/sysinterp.py
==============================================================================
--- pypy/dist/pypy/module/sysinterp.py (original)
+++ pypy/dist/pypy/module/sysinterp.py Wed Jan 26 10:45:04 2005
@@ -122,13 +122,6 @@
# directly from the C code in ceval.c, might be moved somewhere else.
-# this variable is living here, but we
-# access it this way, later:
-# space.sys.recursion_limit = 1000
-# note that we cannot do it *here* because
-# space.sys does not exist, yet.
-recursion_limit = 1000
-
def setrecursionlimit(w_new_limit):
"""setrecursionlimit(n)
@@ -142,7 +135,7 @@
space.wrap("recursion limit must be positive"))
# global recursion_limit
# we need to do it without writing globals.
- space.sys.recursion_limit = new_limit
+ space.recursion_limit = new_limit
def getrecursionlimit():
"""getrecursionlimit()
@@ -151,7 +144,7 @@
of the Python interpreter stack. This limit prevents infinite
recursion from causing an overflow of the C stack and crashing Python."""
- return space.newint(recursion_limit)
+ return space.newint(space.recursion_limit)
checkinterval = 100
More information about the Pypy-commit
mailing list