Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36784)

Unified Diff: Modules/timemodule.c

Issue 5905: strptime fails in non-UTF locale
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- 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 *
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 *
#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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+