mirror of
https://github.com/python/cpython.git
synced 2026-05-07 02:51:00 +00:00
Issue #1548891: The cStringIO.StringIO() constructor now encodes unicode
arguments with the system default encoding just like the write() method does, instead of converting it to a raw buffer.
This commit is contained in:
parent
f678e82240
commit
5a77fe92bd
4 changed files with 31 additions and 5 deletions
|
|
@ -661,7 +661,11 @@ newIobject(PyObject *s) {
|
|||
char *buf;
|
||||
Py_ssize_t size;
|
||||
|
||||
if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
|
||||
if (PyUnicode_Check(s)) {
|
||||
if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0)
|
||||
return NULL;
|
||||
}
|
||||
else if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
|
||||
PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
|
||||
s->ob_type->tp_name);
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue