Skip to content

Commit 3973be1

Browse files
committed
Encode to utf-8 rather than locale
This will cut down on some of the per-environment variability of this function.
1 parent 6494aae commit 3973be1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎Modules/timemodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ time_strftime(PyObject *self, PyObject *args)
735735
fmt = format;
736736
#else
737737
/* Convert the unicode string to an ascii one */
738-
format = PyUnicode_EncodeLocale(format_arg, "surrogateescape");
738+
format = PyUnicode_AsEncodedString(format_arg, "utf-8", "surrogateescape");
739739
if (format == NULL)
740740
return NULL;
741741
fmt = PyBytes_AS_STRING(format);
@@ -809,7 +809,7 @@ time_strftime(PyObject *self, PyObject *args)
809809
#ifdef HAVE_WCSFTIME
810810
ret = PyUnicode_FromWideChar(outbuf, buflen);
811811
#else
812-
ret = PyUnicode_DecodeLocaleAndSize(outbuf, buflen, "surrogateescape");
812+
ret = PyUnicode_Decode(outbuf, buflen, "utf-8", "surrogateescape");
813813
#endif
814814
PyMem_Free(outbuf);
815815
break;

0 commit comments

Comments
 (0)