mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
merge 3.2 (#12878)
This commit is contained in:
commit
9fd5374d4e
3 changed files with 27 additions and 0 deletions
|
@ -610,6 +610,17 @@ class IOTest(unittest.TestCase):
|
||||||
self.assertEqual(rawio.read(2), None)
|
self.assertEqual(rawio.read(2), None)
|
||||||
self.assertEqual(rawio.read(2), b"")
|
self.assertEqual(rawio.read(2), b"")
|
||||||
|
|
||||||
|
def test_types_have_dict(self):
|
||||||
|
test = (
|
||||||
|
self.IOBase(),
|
||||||
|
self.RawIOBase(),
|
||||||
|
self.TextIOBase(),
|
||||||
|
self.StringIO(),
|
||||||
|
self.BytesIO()
|
||||||
|
)
|
||||||
|
for obj in test:
|
||||||
|
self.assertTrue(hasattr(obj, "__dict__"))
|
||||||
|
|
||||||
class CIOTest(IOTest):
|
class CIOTest(IOTest):
|
||||||
|
|
||||||
def test_IOBase_finalize(self):
|
def test_IOBase_finalize(self):
|
||||||
|
|
|
@ -271,6 +271,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #12878: Expose a __dict__ attribute on io.IOBase and its subclasses.
|
||||||
|
|
||||||
- Issue #12636: IDLE reads the coding cookie when executing a Python script.
|
- Issue #12636: IDLE reads the coding cookie when executing a Python script.
|
||||||
|
|
||||||
- Issue #12494: On error, call(), check_call(), check_output() and
|
- Issue #12494: On error, call(), check_call(), check_output() and
|
||||||
|
|
|
@ -156,6 +156,19 @@ iobase_closed_get(PyObject *self, void *context)
|
||||||
return PyBool_FromLong(IS_CLOSED(self));
|
return PyBool_FromLong(IS_CLOSED(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
iobase_get_dict(PyObject *self)
|
||||||
|
{
|
||||||
|
PyObject **dictptr = _PyObject_GetDictPtr(self);
|
||||||
|
PyObject *dict;
|
||||||
|
assert(dictptr);
|
||||||
|
dict = *dictptr;
|
||||||
|
if (dict == NULL)
|
||||||
|
dict = *dictptr = PyDict_New();
|
||||||
|
Py_XINCREF(dict);
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyIOBase_check_closed(PyObject *self, PyObject *args)
|
_PyIOBase_check_closed(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -691,6 +704,7 @@ static PyMethodDef iobase_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyGetSetDef iobase_getset[] = {
|
static PyGetSetDef iobase_getset[] = {
|
||||||
|
{"__dict__", iobase_get_dict, NULL, NULL},
|
||||||
{"closed", (getter)iobase_closed_get, NULL, NULL},
|
{"closed", (getter)iobase_closed_get, NULL, NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue