summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c4
-rw-r--r--Modules/posixmodule.c26
-rw-r--r--Modules/socketmodule.c2
3 files changed, 16 insertions, 16 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index b45eea9ca3..31906bf22b 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4255,7 +4255,7 @@ Array_subscript(PyObject *_self, PyObject *item)
wchar_t *dest;
if (slicelen <= 0)
- return PyUnicode_FromUnicode(NULL, 0);
+ return PyUnicode_New(0, 0);
if (step == 1) {
return PyUnicode_FromWideChar(ptr + start,
slicelen);
@@ -4930,7 +4930,7 @@ Pointer_subscript(PyObject *_self, PyObject *item)
wchar_t *dest;
if (len <= 0)
- return PyUnicode_FromUnicode(NULL, 0);
+ return PyUnicode_New(0, 0);
if (step == 1) {
return PyUnicode_FromWideChar(ptr + start,
len);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 078010b8f0..975cd9afb8 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2599,7 +2599,7 @@ posix_listdir(PyObject *self, PyObject *args)
/* Skip over . and .. */
if (wcscmp(wFileData.cFileName, L".") != 0 &&
wcscmp(wFileData.cFileName, L"..") != 0) {
- v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName));
+ v = PyUnicode_FromWideChar(wFileData.cFileName, wcslen(wFileData.cFileName));
if (v == NULL) {
Py_DECREF(d);
d = NULL;
@@ -2967,7 +2967,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
result = GetFullPathNameW(wpath, result, woutbufp, &wtemp);
}
if (result)
- v = PyUnicode_FromUnicode(woutbufp, wcslen(woutbufp));
+ v = PyUnicode_FromWideChar(woutbufp, wcslen(woutbufp));
else
v = win32_error_object("GetFullPathNameW", po);
if (woutbufp != woutbuf)
@@ -3054,7 +3054,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
return win32_error_object("CloseHandle", po);
target_path[result_length] = 0;
- result = PyUnicode_FromUnicode(target_path, result_length);
+ result = PyUnicode_FromWideChar(target_path, result_length);
free(target_path);
return result;
@@ -7750,7 +7750,7 @@ static PyObject *
posix_putenv(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
- wchar_t *s1, *s2;
+ PyObject *s1, *s2;
wchar_t *newenv;
#else
PyObject *os1, *os2;
@@ -7762,7 +7762,7 @@ posix_putenv(PyObject *self, PyObject *args)
#ifdef MS_WINDOWS
if (!PyArg_ParseTuple(args,
- "uu:putenv",
+ "UU:putenv",
&s1, &s2))
return NULL;
#else
@@ -7799,26 +7799,26 @@ posix_putenv(PyObject *self, PyObject *args)
/* len includes space for a trailing \0; the size arg to
PyBytes_FromStringAndSize does not count that */
#ifdef MS_WINDOWS
- len = wcslen(s1) + wcslen(s2) + 2;
- newstr = PyUnicode_FromUnicode(NULL, (int)len - 1);
-#else
- len = PyBytes_GET_SIZE(os1) + PyBytes_GET_SIZE(os2) + 2;
- newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
-#endif
+ newstr = PyUnicode_FromFormat("%U=%U", s1, s2);
if (newstr == NULL) {
PyErr_NoMemory();
goto error;
}
-#ifdef MS_WINDOWS
newenv = PyUnicode_AsUnicode(newstr);
if (newenv == NULL)
goto error;
- _snwprintf(newenv, len, L"%s=%s", s1, s2);
if (_wputenv(newenv)) {
posix_error();
goto error;
}
#else
+ len = PyBytes_GET_SIZE(os1) + PyBytes_GET_SIZE(os2) + 2;
+ newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
+ if (newstr == NULL) {
+ PyErr_NoMemory();
+ goto error;
+ }
+
newenv = PyBytes_AS_STRING(newstr);
PyOS_snprintf(newenv, len, "%s=%s", s1, s2);
if (putenv(newenv)) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 4742b44b7b..40a18ed3c1 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3900,7 +3900,7 @@ socket_gethostname(PyObject *self, PyObject *unused)
PyObject *result;
if (GetComputerNameExW(ComputerNamePhysicalDnsHostname, buf, &size))
- return PyUnicode_FromUnicode(buf, size);
+ return PyUnicode_FromWideChar(buf, size);
if (GetLastError() != ERROR_MORE_DATA)
return PyErr_SetFromWindowsErr(0);