diff options
author | Thomas Wouters <thomas@python.org> | 2006-02-28 19:02:24 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-02-28 19:02:24 (GMT) |
commit | 34aa7ba11431a46e72ec30ee7528f2e52adbed7f (patch) | |
tree | ac399604026430f720f60a7b42264103a747a18c /Python | |
parent | edc8f1366af2d32882649647a7a79873a6cb9503 (diff) | |
download | cpython-34aa7ba11431a46e72ec30ee7528f2e52adbed7f.zip cpython-34aa7ba11431a46e72ec30ee7528f2e52adbed7f.tar.gz cpython-34aa7ba11431a46e72ec30ee7528f2e52adbed7f.tar.bz2 |
from __future__ import with_statement addon for 'with', mostly written by
Neal.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/Python-ast.c | 4 | ||||
-rw-r--r-- | Python/compile.c | 2 | ||||
-rw-r--r-- | Python/future.c | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 6 |
4 files changed, 10 insertions, 4 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 07de6cb..c4861c3 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -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) diff --git a/Python/compile.c b/Python/compile.c index 78ae6a7..13e0f6d 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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; diff --git a/Python/future.c b/Python/future.c index 0a87b10..4a48ba5 100644 --- a/Python/future.c +++ b/Python/future.c @@ -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"); diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 2a6afe2..d5c86f2 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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) |