[Python-3000-checkins] r66273 - in python/branches/py3k: Misc/NEWS Modules/_dbmmodule.c Modules/mmapmodule.c Modules/ossaudiodev.c PC/winreg.c Python/marshal.c

gregory.p.smith python-3000-checkins at python.org
Sat Sep 6 23:34:51 CEST 2008


Author: gregory.p.smith
Date: Sat Sep  6 23:34:51 2008
New Revision: 66273

Log:
fixes deferred/release blocker issue #3797: Fixed the dbm, marshal, mmap,
ossaudiodev, & winreg modules to return bytes objects instead of bytearray
objects.


Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/_dbmmodule.c
   python/branches/py3k/Modules/mmapmodule.c
   python/branches/py3k/Modules/ossaudiodev.c
   python/branches/py3k/PC/winreg.c
   python/branches/py3k/Python/marshal.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Sep  6 23:34:51 2008
@@ -144,6 +144,9 @@
 - Issue #3492 and #3790: Fixed the zlib module and zipimport module uses of
   mutable bytearray objects where they should have been using immutable bytes.
 
+- Issue #3797: Fixed the dbm, marshal, mmap, ossaudiodev, & winreg modules to
+  return bytes objects instead of bytearray objects.
+
 
 Tools/Demos
 -----------

Modified: python/branches/py3k/Modules/_dbmmodule.c
==============================================================================
--- python/branches/py3k/Modules/_dbmmodule.c	(original)
+++ python/branches/py3k/Modules/_dbmmodule.c	Sat Sep  6 23:34:51 2008
@@ -111,7 +111,7 @@
 		PyErr_SetString(DbmError, "");
 		return NULL;
 	}
-	return PyByteArray_FromStringAndSize(drec.dptr, drec.dsize);
+	return PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
 }
 
 static int
@@ -188,7 +188,7 @@
 		return NULL;
 	for (key = dbm_firstkey(dp->di_dbm); key.dptr;
 	     key = dbm_nextkey(dp->di_dbm)) {
-		item = PyByteArray_FromStringAndSize(key.dptr, key.dsize);
+		item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
 		if (item == NULL) {
 			Py_DECREF(v);
 			return NULL;
@@ -260,7 +260,7 @@
         check_dbmobject_open(dp);
 	val = dbm_fetch(dp->di_dbm, key);
 	if (val.dptr != NULL)
-		return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
+		return PyBytes_FromStringAndSize(val.dptr, val.dsize);
 	else {
 		Py_INCREF(defvalue);
 		return defvalue;
@@ -283,9 +283,9 @@
         check_dbmobject_open(dp);
 	val = dbm_fetch(dp->di_dbm, key);
 	if (val.dptr != NULL)
-		return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
+		return PyBytes_FromStringAndSize(val.dptr, val.dsize);
 	if (defvalue == NULL) {
-		defvalue = PyByteArray_FromStringAndSize(NULL, 0);
+		defvalue = PyBytes_FromStringAndSize(NULL, 0);
 		if (defvalue == NULL)
 			return NULL;
 		val.dptr = NULL;

Modified: python/branches/py3k/Modules/mmapmodule.c
==============================================================================
--- python/branches/py3k/Modules/mmapmodule.c	(original)
+++ python/branches/py3k/Modules/mmapmodule.c	Sat Sep  6 23:34:51 2008
@@ -228,7 +228,7 @@
 	else
 		++eol;		/* we're interested in the position after the
 				   newline. */
-	result = PyByteArray_FromStringAndSize(start, (eol - start));
+	result = PyBytes_FromStringAndSize(start, (eol - start));
 	self->pos += (eol - start);
 	return result;
 }
@@ -248,7 +248,7 @@
 	if (num_bytes > self->size - self->pos) {
 		num_bytes -= (self->pos+num_bytes) - self->size;
 	}
-	result = PyByteArray_FromStringAndSize(self->data+self->pos, num_bytes);
+	result = PyBytes_FromStringAndSize(self->data+self->pos, num_bytes);
 	self->pos += num_bytes;
 	return result;
 }
@@ -679,7 +679,7 @@
 		PyErr_SetString(PyExc_IndexError, "mmap index out of range");
 		return NULL;
 	}
-	return PyByteArray_FromStringAndSize(self->data + i, 1);
+	return PyBytes_FromStringAndSize(self->data + i, 1);
 }
 
 static PyObject *
@@ -769,14 +769,14 @@
 				"mmap object doesn't support item deletion");
 		return -1;
 	}
-	if (! (PyByteArray_Check(v) && PyByteArray_Size(v)==1) ) {
+	if (! (PyBytes_Check(v) && PyBytes_Size(v)==1) ) {
 		PyErr_SetString(PyExc_IndexError,
 				"mmap assignment must be length-1 bytes()");
 		return -1;
 	}
 	if (!is_writable(self))
 		return -1;
-	buf = PyByteArray_AsString(v);
+	buf = PyBytes_AsString(v);
 	self->data[i] = buf[0];
 	return 0;
 }

Modified: python/branches/py3k/Modules/ossaudiodev.c
==============================================================================
--- python/branches/py3k/Modules/ossaudiodev.c	(original)
+++ python/branches/py3k/Modules/ossaudiodev.c	Sat Sep  6 23:34:51 2008
@@ -366,10 +366,10 @@
 
     if (!PyArg_ParseTuple(args, "i:read", &size))
         return NULL;
-    rv = PyByteArray_FromStringAndSize(NULL, size);
+    rv = PyBytes_FromStringAndSize(NULL, size);
     if (rv == NULL)
         return NULL;
-    cp = PyByteArray_AS_STRING(rv);
+    cp = PyBytes_AS_STRING(rv);
 
     Py_BEGIN_ALLOW_THREADS
     count = read(self->fd, cp, size);
@@ -381,7 +381,7 @@
         return NULL;
     }
     self->icount += count;
-    PyByteArray_Resize(rv, count);
+    _PyBytes_Resize(&rv, count);
     return rv;
 }
 

Modified: python/branches/py3k/PC/winreg.c
==============================================================================
--- python/branches/py3k/PC/winreg.c	(original)
+++ python/branches/py3k/PC/winreg.c	Sat Sep  6 23:34:51 2008
@@ -896,7 +896,7 @@
 				obData = Py_None;
 			}
 			else
-				obData = PyByteArray_FromStringAndSize(
+				obData = PyBytes_FromStringAndSize(
 					     (char *)retDataBuf, retDataSize);
 			break;
 	}

Modified: python/branches/py3k/Python/marshal.c
==============================================================================
--- python/branches/py3k/Python/marshal.c	(original)
+++ python/branches/py3k/Python/marshal.c	Sat Sep  6 23:34:51 2008
@@ -1093,7 +1093,7 @@
 	}
 	if (wf.str != NULL) {
 		/* XXX Quick hack -- need to do this differently */
-		res = PyByteArray_FromObject(wf.str);
+		res = PyBytes_FromObject(wf.str);
 		Py_DECREF(wf.str);
 	}
 	return res;
@@ -1134,9 +1134,9 @@
 		rf.ptr = PyBytes_AS_STRING(data);
 		rf.end = rf.ptr + PyBytes_GET_SIZE(data);
 	}
-	else if (PyByteArray_Check(data)) {
-		rf.ptr = PyByteArray_AS_STRING(data);
-		rf.end = rf.ptr + PyByteArray_GET_SIZE(data);
+	else if (PyBytes_Check(data)) {
+		rf.ptr = PyBytes_AS_STRING(data);
+		rf.end = rf.ptr + PyBytes_GET_SIZE(data);
 	}
 	else {
 		PyErr_Format(PyExc_TypeError,


More information about the Python-3000-checkins mailing list