diff options
Diffstat (limited to 'Python/future.c')
-rw-r--r-- | Python/future.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Python/future.c b/Python/future.c index 8097814..81eab54 100644 --- a/Python/future.c +++ b/Python/future.c @@ -11,7 +11,7 @@ "from __future__ imports must occur at the beginning of the file" static int -future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) +future_check_features(PyFutureFeatures *ff, stmt_ty s, PyObject *filename) { int i; asdl_seq *names; @@ -43,12 +43,12 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) } else if (strcmp(feature, "braces") == 0) { PyErr_SetString(PyExc_SyntaxError, "not a chance"); - PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); + PyErr_SyntaxLocationObject(filename, s->lineno, s->col_offset); return 0; } else { PyErr_Format(PyExc_SyntaxError, UNDEFINED_FUTURE_FEATURE, feature); - PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); + PyErr_SyntaxLocationObject(filename, s->lineno, s->col_offset); return 0; } } @@ -56,7 +56,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) } static int -future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) +future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename) { int i, done = 0, prev_line = 0; stmt_ty first; @@ -101,7 +101,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) if (done) { PyErr_SetString(PyExc_SyntaxError, ERR_LATE_FUTURE); - PyErr_SyntaxLocationEx(filename, s->lineno, s->col_offset); + PyErr_SyntaxLocationObject(filename, s->lineno, s->col_offset); return 0; } if (!future_check_features(ff, s, filename)) @@ -121,7 +121,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) PyFutureFeatures * -PyFuture_FromAST(mod_ty mod, const char *filename) +PyFuture_FromASTObject(mod_ty mod, PyObject *filename) { PyFutureFeatures *ff; @@ -139,3 +139,18 @@ PyFuture_FromAST(mod_ty mod, const char *filename) } return ff; } + + +PyFutureFeatures * +PyFuture_FromAST(mod_ty mod, const char *filename_str) +{ + PyFutureFeatures *ff; + PyObject *filename; + + filename = PyUnicode_DecodeFSDefault(filename_str); + if (filename == NULL) + return NULL; + ff = PyFuture_FromASTObject(mod, filename); + Py_DECREF(filename); + return ff; +} |