mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
bpo-36301: Error if decoding pybuilddir.txt fails (GH-12422)
Python initialization now fails if decoding pybuilddir.txt configuration file fails at startup. _PyPathConfig_Calculate() now reports memory allocation failure and decoding error on decoding pybuilddir.txt content from UTF-8/surrogateescape.
This commit is contained in:
parent
7b14f0c02c
commit
5f9cf23502
5 changed files with 32 additions and 16 deletions
|
@ -5064,12 +5064,21 @@ _Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
wchar_t*
|
||||
_Py_DecodeUTF8_surrogateescape(const char *arg, Py_ssize_t arglen)
|
||||
_Py_DecodeUTF8_surrogateescape(const char *arg, Py_ssize_t arglen,
|
||||
size_t *wlen)
|
||||
{
|
||||
wchar_t *wstr;
|
||||
int res = _Py_DecodeUTF8Ex(arg, arglen, &wstr, NULL, NULL, 1);
|
||||
int res = _Py_DecodeUTF8Ex(arg, arglen,
|
||||
&wstr, wlen,
|
||||
NULL, _Py_ERROR_SURROGATEESCAPE);
|
||||
if (res != 0) {
|
||||
/* _Py_DecodeUTF8Ex() must support _Py_ERROR_SURROGATEESCAPE */
|
||||
assert(res != -3);
|
||||
if (wlen) {
|
||||
*wlen = (size_t)res;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return wstr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue