Commit dcb24030 authored by Victor Stinner's avatar Victor Stinner

Issue #8485: PyUnicode_FSConverter() doesn't accept bytearray object anymore,

you have to convert your bytearray filenames to bytes
parent c303c121
......@@ -151,4 +151,6 @@ Porting to Python 3.2
This section lists previously described changes and other bugfixes
that may require changes to your code:
* bytearray objects cannot be used anymore as filenames: convert them to bytes
* Stub
......@@ -1238,8 +1238,8 @@ PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
/* --- File system encoding ---------------------------------------------- */
/* ParseTuple converter which converts a Unicode object into the file
system encoding, using the PEP 383 error handler; bytes objects are
output as-is. */
system encoding as a bytes object, using the PEP 383 error handler; bytes
objects are output as-is. */
PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*);
......
......@@ -815,13 +815,6 @@ class ByteArrayTest(BaseBytesTest):
self.assertRaises(BufferError, delslice)
self.assertEquals(b, orig)
def test_empty_bytearray(self):
# Issue #7561: operations on empty bytearrays could crash in many
# situations, due to a fragile implementation of the
# PyByteArray_AS_STRING() C macro.
self.assertRaises(ValueError, int, bytearray(b''))
self.assertRaises((ValueError, OSError), os.mkdir, bytearray(b''))
class AssortedBytesTest(unittest.TestCase):
#
......
......@@ -607,14 +607,6 @@ 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")
......@@ -872,7 +864,6 @@ class Win32KillTests(unittest.TestCase):
def test_main():
support.run_unittest(
ArgTests,
FileTests,
StatAttributeTests,
EnvironTests,
......
......@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
- Issue #8485: PyUnicode_FSConverter() doesn't accept bytearray object anymore,
you have to convert your bytearray filenames to bytes
- Issue #7332: Remove the 16KB stack-based buffer in
PyMarshal_ReadLastObjectFromFile, which doesn't bring any noticeable
benefit compared to the dynamic memory allocation fallback. Patch by
......
......@@ -271,10 +271,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
if (cwd_obj != Py_None) {
if (PyUnicode_FSConverter(cwd_obj, &cwd_obj2) == 0)
goto cleanup;
if (PyBytes_Check(cwd_obj2))
cwd = PyBytes_AS_STRING(cwd_obj2);
else
cwd = PyByteArray_AS_STRING(cwd_obj2);
cwd = PyBytes_AsString(cwd_obj2);
} else {
cwd = NULL;
cwd_obj2 = NULL;
......
This diff is collapsed.
......@@ -1624,7 +1624,7 @@ PyUnicode_FSConverter(PyObject* arg, void* addr)
Py_DECREF(*(PyObject**)addr);
return 1;
}
if (PyBytes_Check(arg) || PyByteArray_Check(arg)) {
if (PyBytes_Check(arg)) {
output = arg;
Py_INCREF(output);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment