[Python-3000-checkins] r57505 - in python/branches/py3k: Lib/test/test_subprocess.py Modules/posixmodule.c

neal.norwitz python-3000-checkins at python.org
Sun Aug 26 09:10:06 CEST 2007


Author: neal.norwitz
Date: Sun Aug 26 09:10:06 2007
New Revision: 57505

Modified:
   python/branches/py3k/Lib/test/test_subprocess.py
   python/branches/py3k/Modules/posixmodule.c
Log:
Use unicode (and bytes as appropriate)

Modified: python/branches/py3k/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k/Lib/test/test_subprocess.py	Sun Aug 26 09:10:06 2007
@@ -254,7 +254,7 @@
                          stdout=subprocess.PIPE,
                          cwd=tmpdir)
         normcase = os.path.normcase
-        self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
+        self.assertEqual(normcase(p.stdout.read()), bytes(normcase(tmpdir)))
 
     def test_env(self):
         newenv = os.environ.copy()

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Sun Aug 26 09:10:06 2007
@@ -387,13 +387,13 @@
         rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
 	if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
             PyObject *v = PyString_FromString(buffer);
-		    PyDict_SetItemString(d, "BEGINLIBPATH", v);
+	    PyDict_SetItemString(d, "BEGINLIBPATH", v);
             Py_DECREF(v);
         }
         rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
         if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
             PyObject *v = PyString_FromString(buffer);
-		    PyDict_SetItemString(d, "ENDLIBPATH", v);
+	    PyDict_SetItemString(d, "ENDLIBPATH", v);
             Py_DECREF(v);
         }
     }
@@ -1581,7 +1581,7 @@
 #endif
 	if (ret == NULL)
 		return posix_error();
-	return PyString_FromString(ret);
+	return PyUnicode_FromString(ret);
 }
 #endif
 
@@ -1603,7 +1603,7 @@
 #endif
 	if (ret == NULL)
 		return posix_error();
-	return PyString_FromString(buffer);
+	return PyUnicode_FromString(buffer);
 }
 #endif
 
@@ -1883,7 +1883,7 @@
 	Py_END_ALLOW_THREADS
 	if (res == NULL)
 		return posix_error();
-	return PyString_FromString(buf);
+	return PyUnicode_FromString(buf);
 }
 
 PyDoc_STRVAR(posix_getcwdu__doc__,
@@ -3805,7 +3805,7 @@
                                 "unable to determine login name");
         }
         else
-            result = PyString_FromString(name);
+            result = PyUnicode_FromString(name);
         errno = old_errno;
 
     return result;
@@ -5076,7 +5076,7 @@
 				"strerror() argument out of range");
 		return NULL;
 	}
-	return PyString_FromString(message);
+	return PyUnicode_FromString(message);
 }
 #endif /* strerror */
 
@@ -5786,12 +5786,12 @@
         }
         else {
 	    if ((unsigned int)len >= sizeof(buffer)) {
-                result = PyString_FromStringAndSize(NULL, len-1);
+                result = PyUnicode_FromStringAndSize(NULL, len-1);
                 if (result != NULL)
-                    confstr(name, PyString_AS_STRING(result), len);
+                    confstr(name, PyUnicode_AsString(result), len);
             }
             else
-                result = PyString_FromStringAndSize(buffer, len-1);
+                result = PyUnicode_FromStringAndSize(buffer, len-1);
         }
     }
     return result;
@@ -6522,7 +6522,7 @@
 
 PyDoc_STRVAR(win32_urandom__doc__,
 "urandom(n) -> str\n\n\
-Return a string of n random bytes suitable for cryptographic use.");
+Return n random bytes suitable for cryptographic use.");
 
 typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv,\
               LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType,\
@@ -6578,11 +6578,11 @@
 	}
 
 	/* Allocate bytes */
-	result = PyString_FromStringAndSize(NULL, howMany);
+	result = PyBytes_FromStringAndSize(NULL, howMany);
 	if (result != NULL) {
 		/* Get random data */
 		if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
-				      PyString_AS_STRING(result))) {
+				      PyBytes_AS_STRING(result))) {
 			Py_DECREF(result);
 			return win32_error("CryptGenRandom", NULL);
 		}
@@ -6633,7 +6633,7 @@
 #include <openssl/rand.h>
 PyDoc_STRVAR(vms_urandom__doc__,
 "urandom(n) -> str\n\n\
-Return a string of n random bytes suitable for cryptographic use.");
+Return n random bytes suitable for cryptographic use.");
 
 static PyObject*
 vms_urandom(PyObject *self, PyObject *args)
@@ -6649,11 +6649,11 @@
 				    "negative argument not allowed");
 
 	/* Allocate bytes */
-	result = PyString_FromStringAndSize(NULL, howMany);
+	result = PyBytes_FromStringAndSize(NULL, howMany);
 	if (result != NULL) {
 		/* Get random data */
 		if (RAND_pseudo_bytes((unsigned char*)
-				      PyString_AS_STRING(result),
+				      PyBytes_AS_STRING(result),
 				      howMany) < 0) {
 			Py_DECREF(result);
 			return PyErr_Format(PyExc_ValueError,


More information about the Python-3000-checkins mailing list