summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-12-27 20:10:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-12-27 20:10:36 (GMT)
commitcb428f01625f99937b59431a53cc8f6013bd3cc2 (patch)
treee8667e28d2233034831ec06aaaf65cb3a014c7d2
parent8e286c472b4b9c81ef2a3501ac984afe560e29a5 (diff)
downloadcpython-cb428f01625f99937b59431a53cc8f6013bd3cc2.zip
cpython-cb428f01625f99937b59431a53cc8f6013bd3cc2.tar.gz
cpython-cb428f01625f99937b59431a53cc8f6013bd3cc2.tar.bz2
Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
encoding instead of UTF-8.
-rw-r--r--Doc/c-api/exceptions.rst5
-rw-r--r--Include/warnings.h2
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/_warnings.c2
4 files changed, 8 insertions, 4 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 9fec46f..24ca264 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -297,8 +297,9 @@ in various ways. There is a separate error indicator for each thread.
is a straightforward wrapper around the Python function
:func:`warnings.warn_explicit`, see there for more information. The *module*
and *registry* arguments may be set to *NULL* to get the default effect
- described there. *message*, *filename* and *module* are UTF-8 encoded
- strings.
+ described there. *message* and *module* are UTF-8 encoded strings,
+ *filename* is decoded from the filesystem encoding
+ (:func:`sys.getfilesystemencoding`).
.. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...)
diff --git a/Include/warnings.h b/Include/warnings.h
index 7553a25..b7db681 100644
--- a/Include/warnings.h
+++ b/Include/warnings.h
@@ -20,7 +20,7 @@ PyAPI_FUNC(int) PyErr_WarnFormat(
PyAPI_FUNC(int) PyErr_WarnExplicit(
PyObject *category,
const char *message, /* UTF-8 encoded string */
- const char *filename, /* UTF-8 encoded string */
+ const char *filename, /* decoded from the filesystem encoding */
int lineno,
const char *module, /* UTF-8 encoded string */
PyObject *registry);
diff --git a/Misc/NEWS b/Misc/NEWS
index 6c7cb46..4fb23c3 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -8,6 +8,9 @@ What's New in Python 3.2 Release Candidate 1
Core and Builtins
-----------------
+- Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
+ encoding instead of UTF-8.
+
Library
-------
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 87755e1..51c39e4 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -783,7 +783,7 @@ PyErr_WarnExplicit(PyObject *category, const char *text,
{
PyObject *res;
PyObject *message = PyUnicode_FromString(text);
- PyObject *filename = PyUnicode_FromString(filename_str);
+ PyObject *filename = PyUnicode_DecodeFSDefault(filename_str);
PyObject *module = NULL;
int ret = -1;