From: Benjamin Peterson Date: Sun, 14 Jun 2009 18:32:19 +0000 (+0000) Subject: just throw a normal AttributeError for no buffer attribute X-Git-Tag: v3.1~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a38ceda034df6b0be6ed41edbdc28f76e7e7805;p=python just throw a normal AttributeError for no buffer attribute --- diff --git a/Misc/NEWS b/Misc/NEWS index 407681b3d6..1ec5c53cda 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,9 @@ Core and Builtins Library ------- +- Accessing io.StringIO.buffer now raises an AttributeError instead of + io.UnsupportedOperation. + - Issue #6271: mmap tried to close invalid file handle (-1) when annonymous. (On Unix) diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index 57dacf99ae..84a15bedc2 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -645,14 +645,6 @@ stringio_writable(stringio *self, PyObject *args) Py_RETURN_TRUE; } -static PyObject * -stringio_buffer(stringio *self, void *context) -{ - PyErr_SetString(IO_STATE->unsupported_operation, - "buffer attribute is unsupported on type StringIO"); - return NULL; -} - static PyObject * stringio_closed(stringio *self, void *context) { @@ -703,7 +695,6 @@ static PyGetSetDef stringio_getset[] = { Hopefully, a better solution, than adding these pseudo-attributes, will be found. */ - {"buffer", (getter)stringio_buffer, NULL, NULL}, {"line_buffering", (getter)stringio_line_buffering, NULL, NULL}, {NULL} };