mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
add RecursionError
This commit is contained in:
parent
5f35a211fc
commit
054a2a6873
9
src/vm.h
9
src/vm.h
@ -431,6 +431,11 @@ public:
|
||||
|
||||
PyVar _exec(const _Code& code, PyVar _module, PyVarDict& locals){
|
||||
if(code == nullptr) UNREACHABLE();
|
||||
|
||||
if(callstack.size() > 1000){
|
||||
throw RuntimeError("RecursionError", "maximum recursion depth exceeded", _cleanErrorAndGetSnapshots());
|
||||
}
|
||||
|
||||
Frame* frame = new Frame(
|
||||
code.get(),
|
||||
_module,
|
||||
@ -663,7 +668,9 @@ private:
|
||||
std::stack<_Str> _cleanErrorAndGetSnapshots(){
|
||||
std::stack<_Str> snapshots;
|
||||
while (!callstack.empty()){
|
||||
snapshots.push(callstack.top()->errorSnapshot());
|
||||
if(snapshots.size() < 10){
|
||||
snapshots.push(callstack.top()->errorSnapshot());
|
||||
}
|
||||
callstack.pop();
|
||||
}
|
||||
return snapshots;
|
||||
|
@ -17,7 +17,6 @@ var Module = {
|
||||
},
|
||||
'onAbort': function(text) {
|
||||
stopped = true;
|
||||
term.write("Aborted\r\n");
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user