]> granicus.if.org Git - python/commitdiff
Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 27 Dec 2010 20:10:36 +0000 (20:10 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 27 Dec 2010 20:10:36 +0000 (20:10 +0000)
encoding instead of UTF-8.

Doc/c-api/exceptions.rst
Include/warnings.h
Misc/NEWS
Python/_warnings.c

index 9fec46f0c0e6a4bdb6f0f14854f7f6c5548f47ac..24ca264ab6d97b3e9aef434042984e9d877d341c 100644 (file)
@@ -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, ...)
index 7553a25db6386a73e43ef3e98a7be85d95f170d4..b7db681cc41fe007d2e95e439b59bf6ba828d1b7 100644 (file)
@@ -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);
index 6c7cb466bb27c44f23b0e9e9ce6253c48f0a068a..4fb23c3157c6fdecac05f180eb408a0e56b0fef6 100644 (file)
--- 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
 -------
 
index 87755e1edbc5d7c352db54a14c8d12c2620bf9b6..51c39e48d4eb5d989366dd6e5706cdad7ca53c3a 100644 (file)
@@ -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;