add RecursionError

This commit is contained in:
blueloveTH 2022-11-11 18:57:21 +08:00
parent 5f35a211fc
commit 054a2a6873
2 changed files with 8 additions and 2 deletions

View File

@ -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()){
if(snapshots.size() < 10){
snapshots.push(callstack.top()->errorSnapshot());
}
callstack.pop();
}
return snapshots;

View File

@ -17,7 +17,6 @@ var Module = {
},
'onAbort': function(text) {
stopped = true;
term.write("Aborted\r\n");
},
};