From 274dcbcbd978aa3f6d419c82cf2a62aaa263d798 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 6 Mar 2017 22:21:31 -0800 Subject: [PATCH] allow the first call to wcsxfrm to return ERANGE If the output buffer provided to wcsxfrm is too small, errno is set to ERANGE. We should not error out in that case. --- Modules/_localemodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index f5c126a7a1463e..ecd673e4a7dbad 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -262,7 +262,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) } errno = 0; n2 = wcsxfrm(buf, s, n1); - if (errno) { + if (errno && errno != ERANGE) { PyErr_SetFromErrno(PyExc_OSError); goto exit; }