mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Use the new Unicode API
* Replace PyUnicode_FromUnicode(NULL, 0) by PyUnicode_New(0, 0) * Replce PyUnicode_FromUnicode(str, len) by PyUnicode_FromWideChar(str, len) * Replace Py_UNICODE by wchar_t * posix_putenv() uses PyUnicode_FromFormat() to create the string, instead of PyUnicode_FromUnicode() + _snwprintf()
This commit is contained in:
parent
b84d723509
commit
9d3b93ba30
10 changed files with 38 additions and 41 deletions
10
PC/winreg.c
10
PC/winreg.c
|
@ -1227,8 +1227,8 @@ PyEnumValue(PyObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
PyExpandEnvironmentStrings(PyObject *self, PyObject *args)
|
||||
{
|
||||
Py_UNICODE *retValue = NULL;
|
||||
Py_UNICODE *src;
|
||||
wchar_t *retValue = NULL;
|
||||
wchar_t *src;
|
||||
DWORD retValueSize;
|
||||
DWORD rc;
|
||||
PyObject *o;
|
||||
|
@ -1241,7 +1241,7 @@ PyExpandEnvironmentStrings(PyObject *self, PyObject *args)
|
|||
return PyErr_SetFromWindowsErrWithFunction(retValueSize,
|
||||
"ExpandEnvironmentStrings");
|
||||
}
|
||||
retValue = (Py_UNICODE *)PyMem_Malloc(retValueSize * sizeof(Py_UNICODE));
|
||||
retValue = (wchar_t *)PyMem_Malloc(retValueSize * sizeof(wchar_t));
|
||||
if (retValue == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ PyExpandEnvironmentStrings(PyObject *self, PyObject *args)
|
|||
return PyErr_SetFromWindowsErrWithFunction(retValueSize,
|
||||
"ExpandEnvironmentStrings");
|
||||
}
|
||||
o = PyUnicode_FromUnicode(retValue, wcslen(retValue));
|
||||
o = PyUnicode_FromWideChar(retValue, wcslen(retValue));
|
||||
PyMem_Free(retValue);
|
||||
return o;
|
||||
}
|
||||
|
@ -1537,7 +1537,7 @@ PySetValueEx(PyObject *self, PyObject *args)
|
|||
{
|
||||
HKEY hKey;
|
||||
PyObject *obKey;
|
||||
Py_UNICODE *valueName;
|
||||
wchar_t *valueName;
|
||||
PyObject *obRes;
|
||||
PyObject *value;
|
||||
BYTE *data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue