summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-09 19:21:17 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-09 19:21:17 (GMT)
commitdb6238964d534a160f2b2d8b2b61e19a3d3dee47 (patch)
treeed3c1711b5b573b92e21fa9f5877cd766d345da8 /Modules
parent7f54f7590071589e4a7d440a5a7a691f8e92f837 (diff)
parent720f34a3e8567ee7c46ee7d8752617168bfb5258 (diff)
downloadcpython-db6238964d534a160f2b2d8b2b61e19a3d3dee47.zip
cpython-db6238964d534a160f2b2d8b2b61e19a3d3dee47.tar.gz
cpython-db6238964d534a160f2b2d8b2b61e19a3d3dee47.tar.bz2
(Merge 3.2) Issue #5905: time.strftime() is now using the locale encoding,
instead of UTF-8, if the wcsftime() function is not available.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/timemodule.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 52aade4..dff4641 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -30,12 +30,6 @@
#endif /* MS_WINDOWS */
#endif /* !__WATCOMC__ || __QNX__ */
-#if defined(HAVE_MBCS)
-# define TZNAME_ENCODING "mbcs"
-#else
-# define TZNAME_ENCODING "utf-8"
-#endif
-
#if defined(PYOS_OS2)
#define INCL_DOS
#define INCL_ERRORS
@@ -492,7 +486,7 @@ time_strftime(PyObject *self, PyObject *args)
fmt = format;
#else
/* Convert the unicode string to an ascii one */
- format = PyUnicode_AsEncodedString(format_arg, TZNAME_ENCODING, NULL);
+ format = PyUnicode_EncodeFSDefault(format_arg);
if (format == NULL)
return NULL;
fmt = PyBytes_AS_STRING(format);
@@ -536,8 +530,7 @@ time_strftime(PyObject *self, PyObject *args)
#ifdef HAVE_WCSFTIME
ret = PyUnicode_FromWideChar(outbuf, buflen);
#else
- ret = PyUnicode_Decode(outbuf, buflen,
- TZNAME_ENCODING, NULL);
+ ret = PyUnicode_DecodeFSDefaultAndSize(outbuf, buflen);
#endif
PyMem_Free(outbuf);
break;
@@ -769,8 +762,8 @@ PyInit_timezone(PyObject *m) {
#endif /* PYOS_OS2 */
#endif
PyModule_AddIntConstant(m, "daylight", daylight);
- otz0 = PyUnicode_Decode(tzname[0], strlen(tzname[0]), TZNAME_ENCODING, NULL);
- otz1 = PyUnicode_Decode(tzname[1], strlen(tzname[1]), TZNAME_ENCODING, NULL);
+ otz0 = PyUnicode_DecodeFSDefaultAndSize(tzname[0], strlen(tzname[0]));
+ otz1 = PyUnicode_DecodeFSDefaultAndSize(tzname[1], strlen(tzname[1]));
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
#ifdef HAVE_STRUCT_TM_TM_ZONE