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