Only check filenames when end with .py in _CalledFromGeneratedFile() (#4262)
* Cython's stack does not have .py file name. Only check filenames when end with .py for _CalledFromGeneratedFile()
This commit is contained in:
parent
96b535cc2f
commit
e34ec6077a
@ -107,10 +107,6 @@ bool _CalledFromGeneratedFile(int stacklevel) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (frame->f_globals != frame->f_locals) {
|
|
||||||
// Not at global module scope
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame->f_code->co_filename == NULL) {
|
if (frame->f_code->co_filename == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@ -123,6 +119,10 @@ bool _CalledFromGeneratedFile(int stacklevel) {
|
|||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ((filename_size < 3) || (strcmp(&filename[filename_size - 3], ".py") != 0)) {
|
||||||
|
// Cython's stack does not have .py file name and is not at global module scope.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (filename_size < 7) {
|
if (filename_size < 7) {
|
||||||
// filename is too short.
|
// filename is too short.
|
||||||
return false;
|
return false;
|
||||||
@ -131,6 +131,11 @@ bool _CalledFromGeneratedFile(int stacklevel) {
|
|||||||
// Filename is not ending with _pb2.
|
// Filename is not ending with _pb2.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frame->f_globals != frame->f_locals) {
|
||||||
|
// Not at global module scope
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user