aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-03-21 19:53:59 +0000
committerHye-Shik Chang <hyeshik@gmail.com>2004-03-21 19:53:59 +0000
commit07bc3a3db8fe55b597032363d8ead375abfa6ae1 (patch)
tree4f7cf9400600a356da226d2dc6b8ee30e13458a9 /Modules
parentFix test_strftime.py to escape locale time values that have characters that (diff)
downloadcpython-07bc3a3db8fe55b597032363d8ead375abfa6ae1.tar.gz
cpython-07bc3a3db8fe55b597032363d8ead375abfa6ae1.tar.bz2
cpython-07bc3a3db8fe55b597032363d8ead375abfa6ae1.zip
Backport checkin:
[Bug #920575] Add a workaround for GNU libc nl_langinfo()'s returning NULL.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_localemodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 5862c1e59b1..363a823f3df 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -592,8 +592,12 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
}
#endif
for (i = 0; langinfo_constants[i].name; i++)
- if (langinfo_constants[i].value == item)
- return PyString_FromString(nl_langinfo(item));
+ if (langinfo_constants[i].value == item) {
+ /* Check NULL as a workaround for GNU libc's returning NULL
+ instead of an empty string for nl_langinfo(ERA). */
+ const char *result = nl_langinfo(item);
+ return PyString_FromString(result != NULL ? result : "");
+ }
PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant");
return NULL;
}