8000 gh-132775: Add _PyCode_VerifyStateless() by ericsnowcurrently · Pull Request #133221 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132775: Add _PyCode_VerifyStateless() #133221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Prev Previous commit
Next Next commit
Detect globals even if there were no builtins used.
  • Loading branch information
ericsnowcurrently committed May 2, 2025
commit 51ff183c528c7b241e5fc755a92bb69a3a797f63
5 changes: 5 additions & 0 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,11 @@ _PyCode_VerifyStateless(PyThreadState *tstate,
_PyErr_SetString(tstate, PyExc_ValueError, errmsg);
return -1;
}
if (builtinsns != NULL) {
// Make sure the next check will fail for globals,
// even if there aren't any builtins.
counts.unbound.globals.numbuiltin += 1;
}
if (!_PyCode_CheckNoExternalState(co, &counts, &errmsg)) {
_PyErr_SetString(tstate, PyExc_ValueError, errmsg);
return -1;
Expand Down
0