Skip to content

Commit 51ff183

Browse files
Detect globals even if there were no builtins used.
1 parent 2a1ae0e commit 51ff183

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Objects/codeobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,11 @@ _PyCode_VerifyStateless(PyThreadState *tstate,
19971997
_PyErr_SetString(tstate, PyExc_ValueError, errmsg);
19981998
return -1;
19991999
}
2000+
if (builtinsns != NULL) {
2001+
// Make sure the next check will fail for globals,
2002+
// even if there aren't any builtins.
2003+
counts.unbound.globals.numbuiltin += 1;
2004+
}
20002005
if (!_PyCode_CheckNoExternalState(co, &counts, &errmsg)) {
20012006
_PyErr_SetString(tstate, PyExc_ValueError, errmsg);
20022007
return -1;

0 commit comments

Comments
 (0)