summaryrefslogtreecommitdiff
path: root/Modules/cStringIO.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-10-22 21:26:01 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2011-10-22 21:26:01 +0200
commit5a77fe92bd26db11684e4922707d80f654be31dc (patch)
tree47fcd8c286d773367b084741c88df5a8accbfa8e /Modules/cStringIO.c
parentf678e822406a5063b294036f5521c2294a6e20bd (diff)
downloadcpython-git-5a77fe92bd26db11684e4922707d80f654be31dc.tar.gz
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.
Diffstat (limited to 'Modules/cStringIO.c')
-rw-r--r--Modules/cStringIO.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index be9ad50ab6..89f1dd6d2d 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -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;