@@ -2599,7 +2599,7 @@ posix_listdir(PyObject *self, PyObject *args)
25992599 /* Skip over . and .. */
26002600 if (wcscmp (wFileData .cFileName , L"." ) != 0 &&
26012601 wcscmp (wFileData .cFileName , L".." ) != 0 ) {
2602- v = PyUnicode_FromUnicode (wFileData .cFileName , wcslen (wFileData .cFileName ));
2602+ v = PyUnicode_FromWideChar (wFileData .cFileName , wcslen (wFileData .cFileName ));
26032603 if (v == NULL ) {
26042604 Py_DECREF (d );
26052605 d = NULL ;
@@ -2967,7 +2967,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
29672967 result = GetFullPathNameW (wpath , result , woutbufp , & wtemp );
29682968 }
29692969 if (result )
2970- v = PyUnicode_FromUnicode (woutbufp , wcslen (woutbufp ));
2970+ v = PyUnicode_FromWideChar (woutbufp , wcslen (woutbufp ));
29712971 else
29722972 v = win32_error_object ("GetFullPathNameW" , po );
29732973 if (woutbufp != woutbuf )
@@ -3054,7 +3054,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
30543054 return win32_error_object ("CloseHandle" , po );
30553055
30563056 target_path [result_length ] = 0 ;
3057- result = PyUnicode_FromUnicode (target_path , result_length );
3057+ result = PyUnicode_FromWideChar (target_path , result_length );
30583058 free (target_path );
30593059 return result ;
30603060
@@ -7750,7 +7750,7 @@ static PyObject *
77507750posix_putenv (PyObject * self , PyObject * args )
77517751{
77527752#ifdef MS_WINDOWS
7753- wchar_t * s1 , * s2 ;
7753+ PyObject * s1 , * s2 ;
77547754 wchar_t * newenv ;
77557755#else
77567756 PyObject * os1 , * os2 ;
@@ -7762,7 +7762,7 @@ posix_putenv(PyObject *self, PyObject *args)
77627762
77637763#ifdef MS_WINDOWS
77647764 if (!PyArg_ParseTuple (args ,
7765- "uu :putenv" ,
7765+ "UU :putenv" ,
77667766 & s1 , & s2 ))
77677767 return NULL ;
77687768#else
@@ -7799,26 +7799,26 @@ posix_putenv(PyObject *self, PyObject *args)
77997799 /* len includes space for a trailing \0; the size arg to
78007800 PyBytes_FromStringAndSize does not count that */
78017801#ifdef MS_WINDOWS
7802- len = wcslen (s1 ) + wcslen (s2 ) + 2 ;
7803- newstr = PyUnicode_FromUnicode (NULL , (int )len - 1 );
7804- #else
7805- len = PyBytes_GET_SIZE (os1 ) + PyBytes_GET_SIZE (os2 ) + 2 ;
7806- newstr = PyBytes_FromStringAndSize (NULL , (int )len - 1 );
7807- #endif
7802+ newstr = PyUnicode_FromFormat ("%U=%U" , s1 , s2 );
78087803 if (newstr == NULL ) {
78097804 PyErr_NoMemory ();
78107805 goto error ;
78117806 }
7812- #ifdef MS_WINDOWS
78137807 newenv = PyUnicode_AsUnicode (newstr );
78147808 if (newenv == NULL )
78157809 goto error ;
7816- _snwprintf (newenv , len , L"%s=%s" , s1 , s2 );
78177810 if (_wputenv (newenv )) {
78187811 posix_error ();
78197812 goto error ;
78207813 }
78217814#else
7815+ len = PyBytes_GET_SIZE (os1 ) + PyBytes_GET_SIZE (os2 ) + 2 ;
7816+ newstr = PyBytes_FromStringAndSize (NULL , (int )len - 1 );
7817+ if (newstr == NULL ) {
7818+ PyErr_NoMemory ();
7819+ goto error ;
7820+ }
7821+
78227822 newenv = PyBytes_AS_STRING (newstr );
78237823 PyOS_snprintf (newenv , len , "%s=%s" , s1 , s2 );
78247824 if (putenv (newenv )) {
0 commit comments