|
30 | 30 | #endif /* MS_WINDOWS */ |
31 | 31 | #endif /* !__WATCOMC__ || __QNX__ */ |
32 | 32 |
|
33 | | -#if defined(HAVE_MBCS) |
34 | | -# define TZNAME_ENCODING "mbcs" |
35 | | -#else |
36 | | -# define TZNAME_ENCODING "utf-8" |
37 | | -#endif |
38 | | - |
39 | 33 | #if defined(PYOS_OS2) |
40 | 34 | #define INCL_DOS |
41 | 35 | #define INCL_ERRORS |
@@ -492,7 +486,7 @@ time_strftime(PyObject *self, PyObject *args) |
492 | 486 | fmt = format; |
493 | 487 | #else |
494 | 488 | /* Convert the unicode string to an ascii one */ |
495 | | - format = PyUnicode_AsEncodedString(format_arg, TZNAME_ENCODING, NULL); |
| 489 | + format = PyUnicode_EncodeFSDefault(format_arg); |
496 | 490 | if (format == NULL) |
497 | 491 | return NULL; |
498 | 492 | fmt = PyBytes_AS_STRING(format); |
@@ -536,8 +530,7 @@ time_strftime(PyObject *self, PyObject *args) |
536 | 530 | #ifdef HAVE_WCSFTIME |
537 | 531 | ret = PyUnicode_FromWideChar(outbuf, buflen); |
538 | 532 | #else |
539 | | - ret = PyUnicode_Decode(outbuf, buflen, |
540 | | - TZNAME_ENCODING, NULL); |
| 533 | + ret = PyUnicode_DecodeFSDefaultAndSize(outbuf, buflen); |
541 | 534 | #endif |
542 | 535 | PyMem_Free(outbuf); |
543 | 536 | break; |
@@ -769,8 +762,8 @@ PyInit_timezone(PyObject *m) { |
769 | 762 | #endif /* PYOS_OS2 */ |
770 | 763 | #endif |
771 | 764 | PyModule_AddIntConstant(m, "daylight", daylight); |
772 | | - otz0 = PyUnicode_Decode(tzname[0], strlen(tzname[0]), TZNAME_ENCODING, NULL); |
773 | | - otz1 = PyUnicode_Decode(tzname[1], strlen(tzname[1]), TZNAME_ENCODING, NULL); |
| 765 | + otz0 = PyUnicode_DecodeFSDefaultAndSize(tzname[0], strlen(tzname[0])); |
| 766 | + otz1 = PyUnicode_DecodeFSDefaultAndSize(tzname[1], strlen(tzname[1])); |
774 | 767 | PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1)); |
775 | 768 | #else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/ |
776 | 769 | #ifdef HAVE_STRUCT_TM_TM_ZONE |
|
0 commit comments