[Python-checkins] r87517 - in python/branches/py3k: Doc/c-api/exceptions.rst Include/warnings.h Misc/NEWS Python/_warnings.c

victor.stinner python-checkins at python.org
Mon Dec 27 21:10:36 CET 2010


Author: victor.stinner
Date: Mon Dec 27 21:10:36 2010
New Revision: 87517

Log:
Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
encoding instead of UTF-8.


Modified:
   python/branches/py3k/Doc/c-api/exceptions.rst
   python/branches/py3k/Include/warnings.h
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/_warnings.c

Modified: python/branches/py3k/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/exceptions.rst	(original)
+++ python/branches/py3k/Doc/c-api/exceptions.rst	Mon Dec 27 21:10:36 2010
@@ -297,8 +297,9 @@
    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, ...)

Modified: python/branches/py3k/Include/warnings.h
==============================================================================
--- python/branches/py3k/Include/warnings.h	(original)
+++ python/branches/py3k/Include/warnings.h	Mon Dec 27 21:10:36 2010
@@ -20,7 +20,7 @@
 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);

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Dec 27 21:10:36 2010
@@ -8,6 +8,9 @@
 Core and Builtins
 -----------------
 
+- Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
+  encoding instead of UTF-8.
+
 Library
 -------
 

Modified: python/branches/py3k/Python/_warnings.c
==============================================================================
--- python/branches/py3k/Python/_warnings.c	(original)
+++ python/branches/py3k/Python/_warnings.c	Mon Dec 27 21:10:36 2010
@@ -783,7 +783,7 @@
 {
     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;
 


More information about the Python-checkins mailing list