summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-03-21 19:34:30 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-03-21 19:34:30 (GMT)
commitc3a87b8dbbbcc069a58bcbbb0fb5f07858178bca (patch)
treeb0fb371bbf6d0a5c2431b02cae768f0874e2107e /Modules/_localemodule.c
parent56d7913baebe520015c4d25dd1a7469cfd918527 (diff)
downloadcpython-c3a87b8dbbbcc069a58bcbbb0fb5f07858178bca.zip
cpython-c3a87b8dbbbcc069a58bcbbb0fb5f07858178bca.tar.gz
cpython-c3a87b8dbbbcc069a58bcbbb0fb5f07858178bca.tar.bz2
Bug #920575: Add a workaround for GNU libc nl_langinfo()'s returning NULL.
(Reported by Matthias Klose)
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r--Modules/_localemodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 2cfda88..5edb7f3 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;
}