Skip to content

Commit 7503772

Browse files
committed
change if null to assert
1 parent 86c6e57 commit 7503772

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Python/pythonrun.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,22 +1274,18 @@ run_eval_code_obj(PyThreadState *tstate, PyCodeObject *co, PyObject *globals, Py
12741274
// XXX Isn't this dealt with by the move to _PyRuntimeState?
12751275
_PyRuntime.signals.unhandled_keyboard_interrupt = 0;
12761276

1277+
assert(globals);
1278+
12771279
/* Set globals['__builtins__'] if it doesn't exist */
1278-
if (globals == NULL) {
1279-
PyErr_SetString(PyExc_RuntimeError, "globals are NULL");
1280+
int has_builtins = PyDict_ContainsString(globals, "__builtins__");
1281+
if (has_builtins < 0) {
12801282
return NULL;
12811283
}
1282-
else {
1283-
int has_builtins = PyDict_ContainsString(globals, "__builtins__");
1284-
if (has_builtins < 0) {
1284+
if (!has_builtins) {
1285+
if (PyDict_SetItemString(globals, "__builtins__",
1286+
tstate->interp->builtins) < 0) {
12851287
return NULL;
12861288
}
1287-
if (!has_builtins) {
1288-
if (PyDict_SetItemString(globals, "__builtins__",
1289-
tstate->interp->builtins) < 0) {
1290-
return NULL;
1291-
}
1292-
}
12931289
}
12941290

12951291
v = PyEval_EvalCode((PyObject*)co, globals, locals);

0 commit comments

Comments
 (0)