mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-32030: Add _Py_EncodeLocaleRaw() (#4961)
Replace Py_EncodeLocale() with _Py_EncodeLocaleRaw() in: * _Py_wfopen() * _Py_wreadlink() * _Py_wrealpath() * _Py_wstat() * pymain_open_filename() These functions are called early during Python intialization, only the RAW memory allocator must be used.
This commit is contained in:
parent
4a02543cf9
commit
9dd762013f
5 changed files with 101 additions and 41 deletions
|
@ -1490,14 +1490,14 @@ pymain_open_filename(_PyMain *pymain)
|
|||
char *cfilename_buffer;
|
||||
const char *cfilename;
|
||||
int err = errno;
|
||||
cfilename_buffer = Py_EncodeLocale(pymain->filename, NULL);
|
||||
cfilename_buffer = _Py_EncodeLocaleRaw(pymain->filename, NULL);
|
||||
if (cfilename_buffer != NULL)
|
||||
cfilename = cfilename_buffer;
|
||||
else
|
||||
cfilename = "<unprintable file name>";
|
||||
fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n",
|
||||
pymain->config.program, cfilename, err, strerror(err));
|
||||
PyMem_Free(cfilename_buffer);
|
||||
PyMem_RawFree(cfilename_buffer);
|
||||
pymain->status = 2;
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue