summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_os.py9
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/posixmodule.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 62edd6c..907f943 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -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,
diff --git a/Misc/NEWS b/Misc/NEWS
index e77e8a7..c3a9f5c 100644
--- 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.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 688da2c..814c9ba 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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);
}