Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Include/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,10 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeLocale(
const char *errors
);

PyAPI_FUNC(PyObject*) _PyUnicode_DecodeCurrentLocale(
const char *str,
const char *errors);

PyAPI_FUNC(PyObject*) _PyUnicode_DecodeCurrentLocaleAndSize(
const char *str,
Py_ssize_t len,
Expand Down
3 changes: 1 addition & 2 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ encode(PyObject *b)
static PyObject *
decode(const char *s)
{
return _PyUnicode_DecodeCurrentLocaleAndSize(s, strlen(s),
"surrogateescape");
return _PyUnicode_DecodeCurrentLocale(s, "surrogateescape");
}


Expand Down
12 changes: 6 additions & 6 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ tmtotuple(struct tm *p
SET(8, p->tm_isdst);
#ifdef HAVE_STRUCT_TM_TM_ZONE
PyStructSequence_SET_ITEM(v, 9,
PyUnicode_DecodeLocale(p->tm_zone, "surrogateescape"));
_PyUnicode_DecodeCurrentLocale(p->tm_zone, "surrogateescape"));
SET(10, p->tm_gmtoff);
#else
PyStructSequence_SET_ITEM(v, 9,
PyUnicode_DecodeLocale(zone, "surrogateescape"));
_PyUnicode_DecodeCurrentLocale(zone, "surrogateescape"));
PyStructSequence_SET_ITEM(v, 10, _PyLong_FromTime_t(gmtoff));
#endif /* HAVE_STRUCT_TM_TM_ZONE */
#undef SET
Expand Down Expand Up @@ -809,8 +809,8 @@ time_strftime(PyObject *self, PyObject *args)
#ifdef HAVE_WCSFTIME
ret = PyUnicode_FromWideChar(outbuf, buflen);
#else
ret = PyUnicode_DecodeLocaleAndSize(outbuf, buflen,
"surrogateescape");
ret = _PyUnicode_DecodeCurrentLocaleAndSize(outbuf, buflen,
"surrogateescape");
#endif
PyMem_Free(outbuf);
break;
Expand Down Expand Up @@ -1541,8 +1541,8 @@ PyInit_timezone(PyObject *m) {
PyModule_AddIntConstant(m, "altzone", timezone-3600);
#endif
PyModule_AddIntConstant(m, "daylight", daylight);
otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
otz0 = _PyUnicode_DecodeCurrentLocale(tzname[0], "surrogateescape");
otz1 = _PyUnicode_DecodeCurrentLocale(tzname[1], "surrogateescape");
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
{
Expand Down
6 changes: 6 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3836,6 +3836,12 @@ _PyUnicode_DecodeCurrentLocaleAndSize(const char *str, Py_ssize_t len,
return unicode_decode_locale(str, len, errors, 1);
}

PyObject*
_PyUnicode_DecodeCurrentLocale(const char *str, const char *errors)
{
return unicode_decode_locale(str, (Py_ssize_t)strlen(str), errors, 1);
}

PyObject*
PyUnicode_DecodeLocale(const char *str, const char *errors)
{
Expand Down