Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 18611:fdb36a0c7e6e legacy-trunk
Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators
enabled. Doesn't yet work because there's still no way to tell the parser
that "yield" is OK (unlike nested_scopes, the parser has its fingers in
this too).
Replaced PyEval_GetNestedScopes by a more-general
PyEval_MergeCompilerFlags. Perhaps I should not have? I doubted it was
*intended* to be part of the public API, so just did.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Mon, 16 Jul 2001 02:29:45 +0000 |
| parents | 9dda0c11e006 |
| children | 4ac98fe7abd2 |
comparison
equal
deleted
inserted
replaced
| 18610:1f9c7b4cee77 | 18611:fdb36a0c7e6e |
|---|---|
| 492 int ret; | 492 int ret; |
| 493 PyCompilerFlags local_flags; | 493 PyCompilerFlags local_flags; |
| 494 | 494 |
| 495 if (flags == NULL) { | 495 if (flags == NULL) { |
| 496 flags = &local_flags; | 496 flags = &local_flags; |
| 497 local_flags.cf_nested_scopes = 0; | 497 local_flags.cf_flags = 0; |
| 498 } | 498 } |
| 499 v = PySys_GetObject("ps1"); | 499 v = PySys_GetObject("ps1"); |
| 500 if (v == NULL) { | 500 if (v == NULL) { |
| 501 PySys_SetObject("ps1", v = PyString_FromString(">>> ")); | 501 PySys_SetObject("ps1", v = PyString_FromString(">>> ")); |
| 502 Py_XDECREF(v); | 502 Py_XDECREF(v); |
| 1073 } | 1073 } |
| 1074 co = (PyCodeObject *)v; | 1074 co = (PyCodeObject *)v; |
| 1075 v = PyEval_EvalCode(co, globals, locals); | 1075 v = PyEval_EvalCode(co, globals, locals); |
| 1076 if (v && flags) { | 1076 if (v && flags) { |
| 1077 if (co->co_flags & CO_NESTED) | 1077 if (co->co_flags & CO_NESTED) |
| 1078 flags->cf_nested_scopes = 1; | 1078 flags->cf_flags |= PyCF_NESTED_SCOPES; |
| 1079 if (co->co_flags & CO_GENERATOR) | |
| 1080 flags->cf_flags |= PyCF_GENERATORS; | |
| 1079 #if 0 | 1081 #if 0 |
| 1080 fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", | 1082 fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", |
| 1081 flags->cf_nested_scopes); | 1083 flags->cf_flags & PyCF_NESTED_SCOPES); |
| 1084 fprintf(stderr, "run_pyc_file: generators: %d\n", | |
| 1085 flags->cf_flags & PyCF_GENERATORS); | |
| 1082 #endif | 1086 #endif |
| 1083 } | 1087 } |
| 1084 Py_DECREF(co); | 1088 Py_DECREF(co); |
| 1085 return v; | 1089 return v; |
| 1086 } | 1090 } |
