[Bug #920575] Add a workaround for GNU libc nl_langinfo()'s returning NULL.
Library
-------
+- Bug #920575: A problem that _locale module segfaults on
+ nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed.
+
- Bug #883604: Fix Lib/test/test_strftime.py to escape characters from locale
time values that might be mistaken as regex syntax.
}
#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;
}