mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
(Merge 3.2) Issue #5905: time.strftime() is now using the locale encoding,
instead of UTF-8, if the wcsftime() function is not available.
This commit is contained in:
commit
db6238964d
2 changed files with 7 additions and 11 deletions
|
|
@ -406,6 +406,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5905: time.strftime() is now using the locale encoding, instead of
|
||||||
|
UTF-8, if the wcsftime() function is not available.
|
||||||
|
|
||||||
- Issue #8641: Update IDLE 3 syntax coloring to recognize b".." and not u"..".
|
- Issue #8641: Update IDLE 3 syntax coloring to recognize b".." and not u"..".
|
||||||
Patch by Tal Einat.
|
Patch by Tal Einat.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,6 @@
|
||||||
#endif /* MS_WINDOWS */
|
#endif /* MS_WINDOWS */
|
||||||
#endif /* !__WATCOMC__ || __QNX__ */
|
#endif /* !__WATCOMC__ || __QNX__ */
|
||||||
|
|
||||||
#if defined(HAVE_MBCS)
|
|
||||||
# define TZNAME_ENCODING "mbcs"
|
|
||||||
#else
|
|
||||||
# define TZNAME_ENCODING "utf-8"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PYOS_OS2)
|
#if defined(PYOS_OS2)
|
||||||
#define INCL_DOS
|
#define INCL_DOS
|
||||||
#define INCL_ERRORS
|
#define INCL_ERRORS
|
||||||
|
|
@ -492,7 +486,7 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
fmt = format;
|
fmt = format;
|
||||||
#else
|
#else
|
||||||
/* Convert the unicode string to an ascii one */
|
/* Convert the unicode string to an ascii one */
|
||||||
format = PyUnicode_AsEncodedString(format_arg, TZNAME_ENCODING, NULL);
|
format = PyUnicode_EncodeFSDefault(format_arg);
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
fmt = PyBytes_AS_STRING(format);
|
fmt = PyBytes_AS_STRING(format);
|
||||||
|
|
@ -536,8 +530,7 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
#ifdef HAVE_WCSFTIME
|
#ifdef HAVE_WCSFTIME
|
||||||
ret = PyUnicode_FromWideChar(outbuf, buflen);
|
ret = PyUnicode_FromWideChar(outbuf, buflen);
|
||||||
#else
|
#else
|
||||||
ret = PyUnicode_Decode(outbuf, buflen,
|
ret = PyUnicode_DecodeFSDefaultAndSize(outbuf, buflen);
|
||||||
TZNAME_ENCODING, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
PyMem_Free(outbuf);
|
PyMem_Free(outbuf);
|
||||||
break;
|
break;
|
||||||
|
|
@ -769,8 +762,8 @@ PyInit_timezone(PyObject *m) {
|
||||||
#endif /* PYOS_OS2 */
|
#endif /* PYOS_OS2 */
|
||||||
#endif
|
#endif
|
||||||
PyModule_AddIntConstant(m, "daylight", daylight);
|
PyModule_AddIntConstant(m, "daylight", daylight);
|
||||||
otz0 = PyUnicode_Decode(tzname[0], strlen(tzname[0]), TZNAME_ENCODING, NULL);
|
otz0 = PyUnicode_DecodeFSDefaultAndSize(tzname[0], strlen(tzname[0]));
|
||||||
otz1 = PyUnicode_Decode(tzname[1], strlen(tzname[1]), TZNAME_ENCODING, NULL);
|
otz1 = PyUnicode_DecodeFSDefaultAndSize(tzname[1], strlen(tzname[1]));
|
||||||
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
|
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
|
||||||
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
|
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
|
||||||
#ifdef HAVE_STRUCT_TM_TM_ZONE
|
#ifdef HAVE_STRUCT_TM_TM_ZONE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue