Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Dec 21, 2017

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.

https://bugs.python.org/issue32030

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.
len = wcslen(text);

result = PyMem_Malloc(len + 1); /* +1 for NUL byte */
/* +1 for NUL byte */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to your change but should it be "NULL byte" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I only saw your review after I merged my PR. Anyway, I fixed this typo in my following PR: PR #4963.

if (converted == (size_t)-1) {
if (result != NULL)
PyMem_Free(result);
if (result != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, not quite related to your change but if PyMem_RawFree and PyMem_Free behave like free, it should be valid to pass a NULL argument and the test is not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, fixed in PR #4963.

@vstinner vstinner merged commit 9dd7620 into python:master Dec 21, 2017
@vstinner vstinner deleted the encode_raw branch December 21, 2017 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants