summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-04 23:48:03 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-04 23:48:03 (GMT)
commitfe7c5b5bdf7c21551b56be563fc604f2d4d3c756 (patch)
tree831d9e33e02ad3e1c9bf2d0c113a9de8cdad5770 /Python
parent7f2fee36401f7b987a368fe043637b3ae7116600 (diff)
downloadcpython-fe7c5b5bdf7c21551b56be563fc604f2d4d3c756.zip
cpython-fe7c5b5bdf7c21551b56be563fc604f2d4d3c756.tar.gz
cpython-fe7c5b5bdf7c21551b56be563fc604f2d4d3c756.tar.bz2
Issue #9319: Include the filename in "Non-UTF8 code ..." syntax error.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c10
-rw-r--r--Python/traceback.c6
2 files changed, 8 insertions, 8 deletions
diff --git a/Python/import.c b/Python/import.c
index b074b83..4159a8e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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);
diff --git a/Python/traceback.c b/Python/traceback.c
index f0142da..e74a147 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -18,8 +18,8 @@
#define MAX_FRAME_DEPTH 100
#define MAX_NTHREADS 100
-/* Method from Parser/tokenizer.c */
-extern char * PyTokenizer_FindEncoding(int);
+/* Function from Parser/tokenizer.c */
+extern char * PyTokenizer_FindEncodingFilename(int, PyObject *);
static PyObject *
tb_dir(PyTracebackObject *self)
@@ -251,7 +251,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
/* use the right encoding to decode the file as unicode */
fd = PyObject_AsFileDescriptor(binary);
- found_encoding = PyTokenizer_FindEncoding(fd);
+ found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
lseek(fd, 0, 0); /* Reset position */
fob = PyObject_CallMethod(io, "TextIOWrapper", "Os", binary, encoding);