Mercurial > cpython-lru_cache-weakref
comparison Python/bltinmodule.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 | dacbfaa07c40 |
| children | 8e5d6d3103ae |
comparison
equal
deleted
inserted
replaced
| 5437:c2dae2b1a123 | 5438:e926c331ebbf |
|---|---|
| 32 /* Built-in functions */ | 32 /* Built-in functions */ |
| 33 | 33 |
| 34 #include "Python.h" | 34 #include "Python.h" |
| 35 | 35 |
| 36 #include "node.h" | 36 #include "node.h" |
| 37 #include "graminit.h" | |
| 38 #include "compile.h" | 37 #include "compile.h" |
| 39 #include "eval.h" | 38 #include "eval.h" |
| 40 | 39 |
| 41 #include "mymath.h" | 40 #include "mymath.h" |
| 42 | 41 |
| 281 int start; | 280 int start; |
| 282 | 281 |
| 283 if (!PyArg_ParseTuple(args, "sss:compile", &str, &filename, &startstr)) | 282 if (!PyArg_ParseTuple(args, "sss:compile", &str, &filename, &startstr)) |
| 284 return NULL; | 283 return NULL; |
| 285 if (strcmp(startstr, "exec") == 0) | 284 if (strcmp(startstr, "exec") == 0) |
| 286 start = file_input; | 285 start = Py_file_input; |
| 287 else if (strcmp(startstr, "eval") == 0) | 286 else if (strcmp(startstr, "eval") == 0) |
| 288 start = eval_input; | 287 start = Py_eval_input; |
| 289 else if (strcmp(startstr, "single") == 0) | 288 else if (strcmp(startstr, "single") == 0) |
| 290 start = single_input; | 289 start = Py_single_input; |
| 291 else { | 290 else { |
| 292 PyErr_SetString(PyExc_ValueError, | 291 PyErr_SetString(PyExc_ValueError, |
| 293 "compile() mode must be 'exec' or 'eval' or 'single'"); | 292 "compile() mode must be 'exec' or 'eval' or 'single'"); |
| 294 return NULL; | 293 return NULL; |
| 295 } | 294 } |
| 519 "embedded '\\0' in string arg"); | 518 "embedded '\\0' in string arg"); |
| 520 return NULL; | 519 return NULL; |
| 521 } | 520 } |
| 522 while (*str == ' ' || *str == '\t') | 521 while (*str == ' ' || *str == '\t') |
| 523 str++; | 522 str++; |
| 524 return PyRun_String(str, eval_input, globals, locals); | 523 return PyRun_String(str, Py_eval_input, globals, locals); |
| 525 } | 524 } |
| 526 | 525 |
| 527 static PyObject * | 526 static PyObject * |
| 528 builtin_execfile(self, args) | 527 builtin_execfile(self, args) |
| 529 PyObject *self; | 528 PyObject *self; |
| 556 Py_END_ALLOW_THREADS | 555 Py_END_ALLOW_THREADS |
| 557 if (fp == NULL) { | 556 if (fp == NULL) { |
| 558 PyErr_SetFromErrno(PyExc_IOError); | 557 PyErr_SetFromErrno(PyExc_IOError); |
| 559 return NULL; | 558 return NULL; |
| 560 } | 559 } |
| 561 res = PyRun_File(fp, filename, file_input, globals, locals); | 560 res = PyRun_File(fp, filename, Py_file_input, globals, locals); |
| 562 Py_BEGIN_ALLOW_THREADS | 561 Py_BEGIN_ALLOW_THREADS |
| 563 fclose(fp); | 562 fclose(fp); |
| 564 Py_END_ALLOW_THREADS | 563 Py_END_ALLOW_THREADS |
| 565 return res; | 564 return res; |
| 566 } | 565 } |
| 880 if (PyDict_GetItemString(globals, "__builtins__") == NULL) { | 879 if (PyDict_GetItemString(globals, "__builtins__") == NULL) { |
| 881 if (PyDict_SetItemString(globals, "__builtins__", | 880 if (PyDict_SetItemString(globals, "__builtins__", |
| 882 PyEval_GetBuiltins()) != 0) | 881 PyEval_GetBuiltins()) != 0) |
| 883 return NULL; | 882 return NULL; |
| 884 } | 883 } |
| 885 res = PyRun_String(str, eval_input, globals, locals); | 884 res = PyRun_String(str, Py_eval_input, globals, locals); |
| 886 Py_DECREF(line); | 885 Py_DECREF(line); |
| 887 return res; | 886 return res; |
| 888 } | 887 } |
| 889 | 888 |
| 890 static PyObject * | 889 static PyObject * |
