Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e92fba0

Browse files
committed
Get rid of run_err_mod(). It was only used in two places.
One place it wasn't necessary since mod was already checked. Inline the check that mod != NULL for the other use.
1 parent 1fc4b77 commit e92fba0

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

Python/pythonrun.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ extern grammar _PyParser_Grammar; /* From graminit.c */
3636
/* Forward */
3737
static void initmain(void);
3838
static void initsite(void);
39-
static PyObject *run_err_mod(mod_ty, const char *, PyObject *, PyObject *,
40-
PyCompilerFlags *, PyArena *arena);
4139
static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *,
4240
PyCompilerFlags *, PyArena *);
4341
static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
@@ -1159,11 +1157,12 @@ PyObject *
11591157
PyRun_StringFlags(const char *str, int start, PyObject *globals,
11601158
PyObject *locals, PyCompilerFlags *flags)
11611159
{
1162-
PyObject *ret;
1160+
PyObject *ret = NULL;
11631161
PyArena *arena = PyArena_New();
11641162
mod_ty mod = PyParser_ASTFromString(str, "<string>", start, flags,
11651163
arena);
1166-
ret = run_err_mod(mod, "<string>", globals, locals, flags, arena);
1164+
if (mod != NULL)
1165+
ret = run_mod(mod, "<string>", globals, locals, flags, arena);
11671166
PyArena_Free(arena);
11681167
return ret;
11691168
}
@@ -1182,20 +1181,11 @@ PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals,
11821181
}
11831182
if (closeit)
11841183
fclose(fp);
1185-
ret = run_err_mod(mod, filename, globals, locals, flags, arena);
1184+
ret = run_mod(mod, filename, globals, locals, flags, arena);
11861185
PyArena_Free(arena);
11871186
return ret;
11881187
}
11891188

1190-
static PyObject *
1191-
run_err_mod(mod_ty mod, const char *filename, PyObject *globals,
1192-
PyObject *locals, PyCompilerFlags *flags, PyArena *arena)
1193-
{
1194-
if (mod == NULL)
1195-
return NULL;
1196-
return run_mod(mod, filename, globals, locals, flags, arena);
1197-
}
1198-
11991189
static PyObject *
12001190
run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals,
12011191
PyCompilerFlags *flags, PyArena *arena)

0 commit comments

Comments
 (0)