[Python-checkins] r77571 - in python/branches/py3k: Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c

antoine.pitrou python-checkins at python.org
Sun Jan 17 13:16:23 CET 2010


Author: antoine.pitrou
Date: Sun Jan 17 13:16:23 2010
New Revision: 77571

Log:
Issue #7561: Fix crashes when using bytearray objects with the posix
module.



Modified:
   python/branches/py3k/Lib/test/test_os.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/posixmodule.c

Modified: python/branches/py3k/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k/Lib/test/test_os.py	(original)
+++ python/branches/py3k/Lib/test/test_os.py	Sun Jan 17 13:16:23 2010
@@ -564,6 +564,14 @@
     def test_execvpe_with_bad_arglist(self):
         self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
 
+class ArgTests(unittest.TestCase):
+    def test_bytearray(self):
+        # Issue #7561: posix module didn't release bytearray exports properly.
+        b = bytearray(os.sep.encode('ascii'))
+        self.assertRaises(OSError, os.mkdir, b)
+        # Check object is still resizable.
+        b[:] = b''
+
 class Win32ErrorTests(unittest.TestCase):
     def test_rename(self):
         self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak")
@@ -750,6 +758,7 @@
 
 def test_main():
     support.run_unittest(
+        ArgTests,
         FileTests,
         StatAttributeTests,
         EnvironTests,

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Jan 17 13:16:23 2010
@@ -223,6 +223,9 @@
 Library
 -------
 
+- Issue #7561: Fix crashes when using bytearray objects with the posix
+  module.
+
 - Issue #1670765: Prevent email.generator.Generator from re-wrapping
   headers in multipart/signed MIME parts, which fixes one of the sources of
   invalid modifications to such parts by Generator.

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Sun Jan 17 13:16:23 2010
@@ -580,7 +580,7 @@
 release_bytes(PyObject* o)
 {
 	if (PyByteArray_Check(o))
-		o->ob_type->tp_as_buffer->bf_releasebuffer(NULL, 0);
+		o->ob_type->tp_as_buffer->bf_releasebuffer(o, 0);
 	Py_DECREF(o);
 }
 


More information about the Python-checkins mailing list