mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Close #11619: The parser and the import machinery do not encode Unicode
filenames anymore on Windows.
This commit is contained in:
parent
33824f6fd7
commit
14e461d5b9
22 changed files with 514 additions and 175 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue