]> granicus.if.org Git - python/commitdiff
Merged revisions 77571 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 17 Jan 2010 12:19:45 +0000 (12:19 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 17 Jan 2010 12:19:45 +0000 (12:19 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r77571 | antoine.pitrou | 2010-01-17 13:16:23 +0100 (dim., 17 janv. 2010) | 4 lines

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

Lib/test/test_os.py
Misc/NEWS
Modules/posixmodule.c

index 62edd6c4fb9268956cb9ff7e28dfd2d1c819d466..907f94312d86989d02d435a7750be07b04b255fb 100644 (file)
@@ -564,6 +564,14 @@ class ExecTests(unittest.TestCase):
     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 @@ else:
 
 def test_main():
     support.run_unittest(
+        ArgTests,
         FileTests,
         StatAttributeTests,
         EnvironTests,
index e77e8a7432ce5ab26b9d08fc0fd36ae331479b94..c3a9f5c1dc3f3d67ba3045134c946cace675db12 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -67,6 +67,9 @@ Core and Builtins
 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.
index 688da2c339cef512ff7a2a9048239502e1a4c356..814c9bad1b5bbc088f73e9f004fd61eede23b585 100644 (file)
@@ -580,7 +580,7 @@ static void
 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);
 }