mirror of
https://github.com/python/cpython.git
synced 2025-11-08 21:52:45 +00:00
Bug #920575: Add a workaround for GNU libc nl_langinfo()'s returning NULL.
(Reported by Matthias Klose)
This commit is contained in:
parent
56d7913bae
commit
c3a87b8dbb
2 changed files with 9 additions and 2 deletions
|
|
@ -193,6 +193,9 @@ Core and builtins
|
||||||
Extension modules
|
Extension modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Bug #920575: A problem that _locale module segfaults on
|
||||||
|
nl_langinfo(ERA) caused by GNU libc's illegal NULL return is fixed.
|
||||||
|
|
||||||
- array objects now support the copy module. Also, their resizing
|
- array objects now support the copy module. Also, their resizing
|
||||||
scheme has been updated the same as for list objects. The improves
|
scheme has been updated the same as for list objects. The improves
|
||||||
the performance (speed and memory usage) of append() operations.
|
the performance (speed and memory usage) of append() operations.
|
||||||
|
|
|
||||||
|
|
@ -592,8 +592,12 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; langinfo_constants[i].name; i++)
|
for (i = 0; langinfo_constants[i].name; i++)
|
||||||
if (langinfo_constants[i].value == item)
|
if (langinfo_constants[i].value == item) {
|
||||||
return PyString_FromString(nl_langinfo(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");
|
PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue