diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-04 11:43:14 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-04 11:43:14 (GMT) |
commit | 5894ba7fad07dbf07ac76aedf0fb2f70fb42d40e (patch) | |
tree | 60efee02e3d305b57990e816efc8ff0626fa09ac /Objects/unicodeobject.c | |
parent | 9c1257ecf83cc52986995367cedbb093fda140af (diff) | |
download | cpython-5894ba7fad07dbf07ac76aedf0fb2f70fb42d40e.zip cpython-5894ba7fad07dbf07ac76aedf0fb2f70fb42d40e.tar.gz cpython-5894ba7fad07dbf07ac76aedf0fb2f70fb42d40e.tar.bz2 |
Fixed a bug in PyUnicode_DecodeFSDefault. strcmp() returns 0 on success.
Added PyUnicode_DecodeFSDefaultAndSize
Fixed a problem with the sys.path code that caused a segfault on Windows when the path contains non ASCII chars. The code for sys.executable, exec_prefix and prefix should be fixed, too.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 23268f9..c568a8e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1263,10 +1263,14 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode, } PyObject* -PyUnicode_DecodeFSDefault(const char *s) -{ +PyUnicode_DecodeFSDefault(const char *s) { Py_ssize_t size = (Py_ssize_t)strlen(s); + return PyUnicode_DecodeFSDefaultAndSize(s, size); +} +PyObject* +PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size) +{ /* During the early bootstrapping process, Py_FileSystemDefaultEncoding can be undefined. If it is case, decode using UTF-8. The following assumes that Py_FileSystemDefaultEncoding is set to a built-in encoding during the @@ -1274,11 +1278,11 @@ PyUnicode_DecodeFSDefault(const char *s) */ if (Py_FileSystemDefaultEncoding) { #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - if (strcmp(Py_FileSystemDefaultEncoding, "mbcs")) { + if (strcmp(Py_FileSystemDefaultEncoding, "mbcs") == 0) { return PyUnicode_DecodeMBCS(s, size, "replace"); } #elif defined(__APPLE__) - if (strcmp(Py_FileSystemDefaultEncoding, "utf-8")) { + if (strcmp(Py_FileSystemDefaultEncoding, "utf-8") == 0) { return PyUnicode_DecodeUTF8(s, size, "replace"); } #endif |