]> granicus.if.org Git - python/commitdiff
Issue #10780: PyErr_SetFromWindowsErrWithFilename() and
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 28 Dec 2010 00:28:21 +0000 (00:28 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 28 Dec 2010 00:28:21 +0000 (00:28 +0000)
PyErr_SetExcFromWindowsErrWithFilename() decode the filename from the
filesystem encoding instead of UTF-8.

Doc/c-api/exceptions.rst
Include/pyerrors.h
Misc/NEWS
Python/errors.c

index 24ca264ab6d97b3e9aef434042984e9d877d341c..d26e1200c73203160578dc378d0a46fa760f694a 100644 (file)
@@ -219,8 +219,9 @@ in various ways.  There is a separate error indicator for each thread.
 
    Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
    if *filename* is not *NULL*, it is passed to the constructor of
-   :exc:`WindowsError` as a third parameter.  *filename* is decoded from UTF-8.
-   Availability: Windows.
+   :exc:`WindowsError` as a third parameter.  *filename* is decoded from the
+   filesystem encoding (:func:`sys.getfilesystemencoding`).  Availability:
+   Windows.
 
 
 .. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
index 05c5ea8034d08a74aa3c22cdd359fbac04a31fc8..0f8bcf745fedc5e02b6ef3456d6c4430734da7ce 100644 (file)
@@ -202,7 +202,7 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
     int, const char *);
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
     int ierr,
-    const char *filename        /* decoded from UTF-8 */
+    const char *filename,       /* decoded from the filesystem encoding */
     );
 #ifndef Py_LIMITED_API
 /* XXX redeclare to use WSTRING */
@@ -215,7 +215,7 @@ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
     PyObject *exc,
     int ierr,
-    const char *filename        /* decoded from UTF-8 */
+    const char *filename,       /* decoded from the filesystem encoding */
     );
 #ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
index 4fb23c3157c6fdecac05f180eb408a0e56b0fef6..7d2085afda8cc24144124ea2d0e598361f0e2ff0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -8,6 +8,10 @@ What's New in Python 3.2 Release Candidate 1
 Core and Builtins
 -----------------
 
+- Issue #10780: PyErr_SetFromWindowsErrWithFilename() and
+  PyErr_SetExcFromWindowsErrWithFilename() decode the filename from the
+  filesystem encoding instead of UTF-8.
+
 - Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
   encoding instead of UTF-8.
 
index d5a6fae0b4173689dfb07b608ece31f3aca01831..5a9a624279ddf86430bed890f122890da46adcfb 100644 (file)
@@ -515,7 +515,7 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilename(
     int ierr,
     const char *filename)
 {
-    PyObject *name = filename ? PyUnicode_FromString(filename) : NULL;
+    PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
     PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc,
                                                                  ierr,
                                                                  name);
@@ -552,7 +552,7 @@ PyObject *PyErr_SetFromWindowsErrWithFilename(
     int ierr,
     const char *filename)
 {
-    PyObject *name = filename ? PyUnicode_FromString(filename) : NULL;
+    PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
     PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
                                                   PyExc_WindowsError,
                                                   ierr, name);