summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-21 15:20:32 (GMT)
committerGitHub <noreply@github.com>2017-12-21 15:20:32 (GMT)
commit9dd762013fd9fcf975ad51700b55d050ca9ed60e (patch)
tree67e0bcd6b3884cfa23d983bb722ee492c8c5aad9 /Modules
parent4a02543cf97e8cbf9293741379f977b85531e4c2 (diff)
downloadcpython-9dd762013fd9fcf975ad51700b55d050ca9ed60e.zip
cpython-9dd762013fd9fcf975ad51700b55d050ca9ed60e.tar.gz
cpython-9dd762013fd9fcf975ad51700b55d050ca9ed60e.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c4
-rw-r--r--Modules/main.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index b4b3343..494fa19 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -140,13 +140,13 @@ _Py_wstat(const wchar_t* path, struct stat *buf)
{
int err;
char *fname;
- fname = Py_EncodeLocale(path, NULL);
+ fname = _Py_EncodeLocaleRaw(path, NULL);
if (fname == NULL) {
errno = EINVAL;
return -1;
}
err = stat(fname, buf);
- PyMem_Free(fname);
+ PyMem_RawFree(fname);
return err;
}
diff --git a/Modules/main.c b/Modules/main.c
index 1bf706b..dff7894 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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;
}