Issue #9319: Include the filename in "Non-UTF8 code ..." syntax error.

This commit is contained in:
Victor Stinner 2011-04-05 01:48:03 +02:00
parent 7f2fee3640
commit fe7c5b5bdf
6 changed files with 43 additions and 23 deletions

View file

@ -124,12 +124,12 @@ static const Py_UNICODE PYC_TAG_UNICODE[] = {
/* See _PyImport_FixupExtensionObject() below */
static PyObject *extensions = NULL;
/* Function from Parser/tokenizer.c */
extern char * PyTokenizer_FindEncodingFilename(int, PyObject *);
/* This table is defined in config.c: */
extern struct _inittab _PyImport_Inittab[];
/* Method from Parser/tokenizer.c */
extern char * PyTokenizer_FindEncoding(int);
struct _inittab *PyImport_Inittab = _PyImport_Inittab;
/* these tables define the module suffixes that Python recognizes */
@ -3540,9 +3540,9 @@ call_find_module(PyObject *name, PyObject *path_list)
}
if (fd != -1) {
if (strchr(fdp->mode, 'b') == NULL) {
/* PyTokenizer_FindEncoding() returns PyMem_MALLOC'ed
/* PyTokenizer_FindEncodingFilename() returns PyMem_MALLOC'ed
memory. */
found_encoding = PyTokenizer_FindEncoding(fd);
found_encoding = PyTokenizer_FindEncodingFilename(fd, pathobj);
lseek(fd, 0, 0); /* Reset position */
if (found_encoding == NULL && PyErr_Occurred()) {
Py_XDECREF(pathobj);