summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-16 22:56:01 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-16 22:56:01 (GMT)
commitaf02e1c85a66009cdc645a64de7d7ee1335c8301 (patch)
tree5bc78c3a8628589cf5a4c246afc0076871d51c62 /Modules/timemodule.c
parent3607e3de278c89660f773064a94385066eebda1b (diff)
downloadcpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.zip
cpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.tar.gz
cpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.tar.bz2
Add PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale()
* PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale() decode a string from the current locale encoding * _Py_char2wchar() writes an "error code" in the size argument to indicate if the function failed because of memory allocation failure or because of a decoding error. The function doesn't write the error message directly to stderr. * Fix time.strftime() (if wcsftime() is missing): decode strftime() result from the current locale encoding, not from the filesystem encoding.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 001b311..a46c4f1 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -532,7 +532,7 @@ time_strftime(PyObject *self, PyObject *args)
#ifdef HAVE_WCSFTIME
ret = PyUnicode_FromWideChar(outbuf, buflen);
#else
- ret = PyUnicode_DecodeFSDefaultAndSize(outbuf, buflen);
+ ret = PyUnicode_DecodeLocaleAndSize(outbuf, buflen, 1);
#endif
PyMem_Free(outbuf);
break;
@@ -764,8 +764,8 @@ PyInit_timezone(PyObject *m) {
#endif /* PYOS_OS2 */
#endif
PyModule_AddIntConstant(m, "daylight", daylight);
- otz0 = PyUnicode_DecodeFSDefaultAndSize(tzname[0], strlen(tzname[0]));
- otz1 = PyUnicode_DecodeFSDefaultAndSize(tzname[1], strlen(tzname[1]));
+ otz0 = PyUnicode_DecodeLocale(tzname[0], 1);
+ otz1 = PyUnicode_DecodeLocale(tzname[1], 1);
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
#ifdef HAVE_STRUCT_TM_TM_ZONE