Commit 3bb00703 authored by Martin v. Löwis's avatar Martin v. Löwis

Explicitly convert tzname to Unicode. Fixes #1040.

parent 2cc1f6d9
...@@ -55,6 +55,7 @@ static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType) ...@@ -55,6 +55,7 @@ static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType)
} }
static long main_thread; static long main_thread;
#define TZNAME_ENCODING "utf-8"
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
/* These overrides not needed for Win32 */ /* These overrides not needed for Win32 */
...@@ -68,6 +69,8 @@ static long main_thread; ...@@ -68,6 +69,8 @@ static long main_thread;
#if defined(MS_WINDOWS) && !defined(__BORLANDC__) #if defined(MS_WINDOWS) && !defined(__BORLANDC__)
/* Win32 has better clock replacement; we have our own version below. */ /* Win32 has better clock replacement; we have our own version below. */
#undef HAVE_CLOCK #undef HAVE_CLOCK
#undef TZNAME_ENCODING
#define TZNAME_ENCODING "mbcs"
#endif /* MS_WINDOWS && !defined(__BORLANDC__) */ #endif /* MS_WINDOWS && !defined(__BORLANDC__) */
#if defined(PYOS_OS2) #if defined(PYOS_OS2)
...@@ -710,6 +713,7 @@ void inittimezone(PyObject *m) { ...@@ -710,6 +713,7 @@ void inittimezone(PyObject *m) {
And I'm lazy and hate C so nyer. And I'm lazy and hate C so nyer.
*/ */
#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) #if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__)
PyObject *otz0, *otz1;
tzset(); tzset();
#ifdef PYOS_OS2 #ifdef PYOS_OS2
PyModule_AddIntConstant(m, "timezone", _timezone); PyModule_AddIntConstant(m, "timezone", _timezone);
...@@ -726,8 +730,9 @@ void inittimezone(PyObject *m) { ...@@ -726,8 +730,9 @@ void inittimezone(PyObject *m) {
#endif /* PYOS_OS2 */ #endif /* PYOS_OS2 */
#endif #endif
PyModule_AddIntConstant(m, "daylight", daylight); PyModule_AddIntConstant(m, "daylight", daylight);
PyModule_AddObject(m, "tzname", otz0 = PyUnicode_Decode(tzname[0], strlen(tzname[0]), TZNAME_ENCODING, NULL);
Py_BuildValue("(zz)", tzname[0], tzname[1])); otz1 = PyUnicode_Decode(tzname[1], strlen(tzname[1]), TZNAME_ENCODING, NULL);
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
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment