comparison Python/pythonrun.c @ 5438:e926c331ebbf legacy-trunk

Instead of importing graminit.h whenever one of the three grammar 'root' symbols is needed, define these in Python.h with a Py_ prefix.
author Guido van Rossum <guido@python.org>
date Wed, 07 May 1997 17:46:13 +0000
parents 596380a567d2
children 451c7ccf36b6
comparison
equal deleted inserted replaced
5437:c2dae2b1a123 5438:e926c331ebbf
34 #include "Python.h" 34 #include "Python.h"
35 35
36 #include "grammar.h" 36 #include "grammar.h"
37 #include "node.h" 37 #include "node.h"
38 #include "parsetok.h" 38 #include "parsetok.h"
39 #include "graminit.h"
40 #undef argument /* Avoid conflict on Mac */ 39 #undef argument /* Avoid conflict on Mac */
41 #include "errcode.h" 40 #include "errcode.h"
42 #include "compile.h" 41 #include "compile.h"
43 #include "eval.h" 42 #include "eval.h"
44 #include "marshal.h" 43 #include "marshal.h"
235 w = NULL; 234 w = NULL;
236 ps2 = ""; 235 ps2 = "";
237 } 236 }
238 Py_BEGIN_ALLOW_THREADS 237 Py_BEGIN_ALLOW_THREADS
239 n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, 238 n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar,
240 single_input, ps1, ps2, &err); 239 Py_single_input, ps1, ps2, &err);
241 Py_END_ALLOW_THREADS 240 Py_END_ALLOW_THREADS
242 Py_XDECREF(v); 241 Py_XDECREF(v);
243 Py_XDECREF(w); 242 Py_XDECREF(w);
244 if (n == NULL) { 243 if (n == NULL) {
245 if (err.error == E_EOF) { 244 if (err.error == E_EOF) {
294 /* Turn on optimization if a .pyo file is given */ 293 /* Turn on optimization if a .pyo file is given */
295 if (strcmp(ext, ".pyo") == 0) 294 if (strcmp(ext, ".pyo") == 0)
296 Py_OptimizeFlag = 1; 295 Py_OptimizeFlag = 1;
297 v = run_pyc_file(fp, filename, d, d); 296 v = run_pyc_file(fp, filename, d, d);
298 } else { 297 } else {
299 v = PyRun_File(fp, filename, file_input, d, d); 298 v = PyRun_File(fp, filename, Py_file_input, d, d);
300 } 299 }
301 if (v == NULL) { 300 if (v == NULL) {
302 PyErr_Print(); 301 PyErr_Print();
303 return -1; 302 return -1;
304 } 303 }
314 PyObject *m, *d, *v; 313 PyObject *m, *d, *v;
315 m = PyImport_AddModule("__main__"); 314 m = PyImport_AddModule("__main__");
316 if (m == NULL) 315 if (m == NULL)
317 return -1; 316 return -1;
318 d = PyModule_GetDict(m); 317 d = PyModule_GetDict(m);
319 v = PyRun_String(command, file_input, d, d); 318 v = PyRun_String(command, Py_file_input, d, d);
320 if (v == NULL) { 319 if (v == NULL) {
321 PyErr_Print(); 320 PyErr_Print();
322 return -1; 321 return -1;
323 } 322 }
324 Py_DECREF(v); 323 Py_DECREF(v);