mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
from __future__ import with_statement addon for 'with', mostly written by
Neal.
This commit is contained in:
parent
edc8f1366a
commit
34aa7ba114
16 changed files with 102 additions and 40 deletions
|
@ -371,7 +371,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
|
|||
}
|
||||
PyTuple_SET_ITEM(fnames, i, field);
|
||||
}
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
|
||||
type, base, "_fields", fnames, "__module__", "_ast");
|
||||
Py_DECREF(fnames);
|
||||
return (PyTypeObject*)result;
|
||||
|
@ -2956,7 +2956,7 @@ init_ast(void)
|
|||
if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
|
||||
if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
|
||||
return;
|
||||
if (PyModule_AddStringConstant(m, "__version__", "42635") < 0)
|
||||
if (PyModule_AddStringConstant(m, "__version__", "42649") < 0)
|
||||
return;
|
||||
if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
|
||||
if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
|
||||
|
|
|
@ -4286,6 +4286,8 @@ compute_code_flags(struct compiler *c)
|
|||
flags |= CO_GENERATOR;
|
||||
if (c->c_flags->cf_flags & CO_FUTURE_DIVISION)
|
||||
flags |= CO_FUTURE_DIVISION;
|
||||
if (c->c_flags->cf_flags & CO_FUTURE_WITH_STATEMENT)
|
||||
flags |= CO_FUTURE_WITH_STATEMENT;
|
||||
n = PyDict_Size(c->u->u_freevars);
|
||||
if (n < 0)
|
||||
return -1;
|
||||
|
|
|
@ -31,6 +31,8 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
|
|||
ff->ff_features |= CO_FUTURE_DIVISION;
|
||||
} else if (strcmp(feature, FUTURE_ABSIMPORT) == 0) {
|
||||
ff->ff_features |= CO_FUTURE_ABSIMPORT;
|
||||
} else if (strcmp(feature, FUTURE_WITH_STATEMENT) == 0) {
|
||||
ff->ff_features |= CO_FUTURE_WITH_STATEMENT;
|
||||
} else if (strcmp(feature, "braces") == 0) {
|
||||
PyErr_SetString(PyExc_SyntaxError,
|
||||
"not a chance");
|
||||
|
|
|
@ -690,8 +690,10 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
|
|||
|
||||
/* compute parser flags based on compiler flags */
|
||||
#define PARSER_FLAGS(flags) \
|
||||
(((flags) && (flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
|
||||
PyPARSE_DONT_IMPLY_DEDENT : 0)
|
||||
((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
|
||||
PyPARSE_DONT_IMPLY_DEDENT : 0) \
|
||||
| ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
|
||||
PyPARSE_WITH_IS_KEYWORD : 0)) : 0)
|
||||
|
||||
int
|
||||
PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue