From e49e204c2882b1c702750414451e229d3ef37268 Mon Sep 17 00:00:00 2001 From: BLUELOVETH Date: Tue, 18 Apr 2023 06:34:52 +0000 Subject: [PATCH] ... --- src/pocketpy.h | 5 ----- src/vm.h | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/pocketpy.h b/src/pocketpy.h index fa7a8b10..62b0f322 100644 --- a/src/pocketpy.h +++ b/src/pocketpy.h @@ -590,11 +590,6 @@ inline void add_module_time(VM* vm){ inline void add_module_sys(VM* vm){ PyObject* mod = vm->new_module("sys"); vm->setattr(mod, "version", VAR(PK_VERSION)); - vm->bind_func<0>(mod, "getrecursionlimit", CPP_LAMBDA(VAR(vm->recursionlimit))); - vm->bind_func<1>(mod, "setrecursionlimit", [](VM* vm, ArgsView args) { - vm->recursionlimit = CAST(int, args[0]); - return vm->None; - }); } inline void add_module_json(VM* vm){ diff --git a/src/vm.h b/src/vm.h index aa60ecb6..8f80bca9 100644 --- a/src/vm.h +++ b/src/vm.h @@ -104,8 +104,6 @@ public: Type tp_slice, tp_range, tp_module; Type tp_super, tp_exception; - i64 recursionlimit = 1000; - VM(bool use_stdio) : heap(this){ this->vm = this; this->_stdout = use_stdio ? &std::cout : &_stdout_buffer; @@ -331,7 +329,6 @@ public: } void StackOverflowError() { _error("StackOverflowError", ""); } - void RecursionError() { _error("RecursionError", "maximum recursion depth exceeded"); } void IOError(const Str& msg) { _error("IOError", msg); } void NotImplementedError(){ _error("NotImplementedError", ""); } void TypeError(const Str& msg){ _error("TypeError", msg); } @@ -866,7 +863,7 @@ inline PyObject* VM::vectorcall(int ARGC, int KWARGC, bool op_call){ inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args, ArgsView kwargs){ // callable must be a `function` object - if(callstack.size() >= recursionlimit) RecursionError(); + if(s_data.is_overflow()) StackOverflowError(); const Function& fn = CAST(Function&, callable); const CodeObject* co = fn.decl->code.get();