comparison Python/pythonrun.c @ 36835:9109b1a0d265 legacy-trunk

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.
author Neal Norwitz <nnorwitz@gmail.com>
date Sat, 04 Mar 2006 18:52:26 +0000
parents de4816d344ee
children 01bc8ee3d2ff
comparison
equal deleted inserted replaced
36834:0b7809660456 36835:9109b1a0d265
34 extern grammar _PyParser_Grammar; /* From graminit.c */ 34 extern grammar _PyParser_Grammar; /* From graminit.c */
35 35
36 /* Forward */ 36 /* Forward */
37 static void initmain(void); 37 static void initmain(void);
38 static void initsite(void); 38 static void initsite(void);
39 static PyObject *run_err_mod(mod_ty, const char *, PyObject *, PyObject *,
40 PyCompilerFlags *, PyArena *arena);
41 static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, 39 static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *,
42 PyCompilerFlags *, PyArena *); 40 PyCompilerFlags *, PyArena *);
43 static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, 41 static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
44 PyCompilerFlags *); 42 PyCompilerFlags *);
45 static void err_input(perrdetail *); 43 static void err_input(perrdetail *);
1157 1155
1158 PyObject * 1156 PyObject *
1159 PyRun_StringFlags(const char *str, int start, PyObject *globals, 1157 PyRun_StringFlags(const char *str, int start, PyObject *globals,
1160 PyObject *locals, PyCompilerFlags *flags) 1158 PyObject *locals, PyCompilerFlags *flags)
1161 { 1159 {
1162 PyObject *ret; 1160 PyObject *ret = NULL;
1163 PyArena *arena = PyArena_New(); 1161 PyArena *arena = PyArena_New();
1164 mod_ty mod = PyParser_ASTFromString(str, "<string>", start, flags, 1162 mod_ty mod = PyParser_ASTFromString(str, "<string>", start, flags,
1165 arena); 1163 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);
1167 PyArena_Free(arena); 1166 PyArena_Free(arena);
1168 return ret; 1167 return ret;
1169 } 1168 }
1170 1169
1171 PyObject * 1170 PyObject *
1180 PyArena_Free(arena); 1179 PyArena_Free(arena);
1181 return NULL; 1180 return NULL;
1182 } 1181 }
1183 if (closeit) 1182 if (closeit)
1184 fclose(fp); 1183 fclose(fp);
1185 ret = run_err_mod(mod, filename, globals, locals, flags, arena); 1184 ret = run_mod(mod, filename, globals, locals, flags, arena);
1186 PyArena_Free(arena); 1185 PyArena_Free(arena);
1187 return ret; 1186 return ret;
1188 }
1189
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 } 1187 }
1198 1188
1199 static PyObject * 1189 static PyObject *
1200 run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals, 1190 run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals,
1201 PyCompilerFlags *flags, PyArena *arena) 1191 PyCompilerFlags *flags, PyArena *arena)