summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-17 19:16:33 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-17 19:16:33 (GMT)
commitc049982ea5dd26282e82d4874a0854df617ec45e (patch)
treef31795953a7a7c3124ddfcb841f28f573adaeabf
parent15a71cdad2537b9ffcfe7216ea9af61d7888db98 (diff)
downloadcpython-c049982ea5dd26282e82d4874a0854df617ec45e.zip
cpython-c049982ea5dd26282e82d4874a0854df617ec45e.tar.gz
cpython-c049982ea5dd26282e82d4874a0854df617ec45e.tar.bz2
compiler_error(): use PyUnicode_DecodeFSDefault() to decode the filename,
instead of utf-8 in strict mode.
-rw-r--r--Python/compile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 1ff0859..fb27596 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3361,7 +3361,7 @@ compiler_in_loop(struct compiler *c) {
static int
compiler_error(struct compiler *c, const char *errstr)
{
- PyObject *loc;
+ PyObject *loc, *filename;
PyObject *u = NULL, *v = NULL;
loc = PyErr_ProgramText(c->c_filename, c->u->u_lineno);
@@ -3369,7 +3369,16 @@ compiler_error(struct compiler *c, const char *errstr)
Py_INCREF(Py_None);
loc = Py_None;
}
- u = Py_BuildValue("(ziiO)", c->c_filename, c->u->u_lineno,
+ if (c->c_filename != NULL) {
+ filename = PyUnicode_DecodeFSDefault(c->c_filename);
+ if (!filename)
+ goto exit;
+ }
+ else {
+ Py_INCREF(Py_None);
+ filename = Py_None;
+ }
+ u = Py_BuildValue("(NiiO)", filename, c->u->u_lineno,
c->u->u_col_offset, loc);
if (!u)
goto exit;