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);
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);
/* 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;
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)
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;
posix_putenv(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
- wchar_t *s1, *s2;
+ PyObject *s1, *s2;
wchar_t *newenv;
#else
PyObject *os1, *os2;
#ifdef MS_WINDOWS
if (!PyArg_ParseTuple(args,
- "uu:putenv",
+ "UU:putenv",
&s1, &s2))
return NULL;
#else
/* 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)) {
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);
/* If no format_spec is provided, use an empty string */
if (format_spec == NULL) {
- empty = PyUnicode_FromUnicode(NULL, 0);
+ empty = PyUnicode_New(0, 0);
format_spec = empty;
}
uuidcreate(PyObject* obj, PyObject*args)
{
UUID result;
- unsigned short *cresult;
+ wchar_t *cresult;
PyObject *oresult;
/* May return ok, local only, and no address.
return NULL;
}
- oresult = PyUnicode_FromUnicode(cresult, wcslen(cresult));
+ oresult = PyUnicode_FromWideChar(cresult, wcslen(cresult));
RpcStringFreeW(&cresult);
return oresult;
}
if (status != ERROR_SUCCESS)
return msierror((int) status);
- string = PyUnicode_FromUnicode(res, size);
+ string = PyUnicode_FromWideChar(res, size);
if (buf != res)
free(res);
return string;
{
int status;
int field;
- Py_UNICODE *data;
+ wchar_t *data;
if (!PyArg_ParseTuple(args, "iu:SetString", &field, &data))
return NULL;
{
int status;
int field;
- Py_UNICODE *data;
+ wchar_t *data;
if (!PyArg_ParseTuple(args, "iu:SetStream", &field, &data))
return NULL;
PyObject* environment;
wchar_t *wenvironment;
- Py_UNICODE* application_name;
- Py_UNICODE* command_line;
+ wchar_t* application_name;
+ wchar_t* command_line;
PyObject* process_attributes; /* ignored */
PyObject* thread_attributes; /* ignored */
int inherit_handles;
int creation_flags;
PyObject* env_mapping;
- Py_UNICODE* current_directory;
+ wchar_t* current_directory;
PyObject* startup_info;
if (! PyArg_ParseTuple(args, "ZZOOiiOZO:CreateProcess",
if (PyErr_Occurred())
return NULL;
- if (env_mapping == Py_None)
- environment = NULL;
- else {
+ if (env_mapping != Py_None) {
environment = getenvironment(env_mapping);
if (! environment)
return NULL;
- }
-
- if (environment) {
wenvironment = PyUnicode_AsUnicode(environment);
if (wenvironment == NULL)
{
return NULL;
}
}
- else
+ else {
+ environment = NULL;
wenvironment = NULL;
+ }
Py_BEGIN_ALLOW_THREADS
result = CreateProcessW(application_name,
static PyObject *
msvcrt_getwch(PyObject *self, PyObject *args)
{
- Py_UNICODE ch;
+ wchar_t ch;
if (!PyArg_ParseTuple(args, ":getwch"))
return NULL;
static PyObject *
msvcrt_getwche(PyObject *self, PyObject *args)
{
- Py_UNICODE ch;
+ wchar_t ch;
if (!PyArg_ParseTuple(args, ":getwche"))
return NULL;
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;
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();
}
return PyErr_SetFromWindowsErrWithFunction(retValueSize,
"ExpandEnvironmentStrings");
}
- o = PyUnicode_FromUnicode(retValue, wcslen(retValue));
+ o = PyUnicode_FromWideChar(retValue, wcslen(retValue));
PyMem_Free(retValue);
return o;
}
{
HKEY hKey;
PyObject *obKey;
- Py_UNICODE *valueName;
+ wchar_t *valueName;
PyObject *obRes;
PyObject *value;
BYTE *data;
static PyObject *
sound_playsound(PyObject *s, PyObject *args)
{
- Py_UNICODE *wsound;
+ wchar_t *wsound;
int flags;
int ok;
"DLL load failed: ");
PyUnicode_AppendAndDel(&message,
- PyUnicode_FromUnicode(
+ PyUnicode_FromWideChar(
theInfo,
theLength));
}