Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f6f3a354
Commit
f6f3a354
authored
Sep 03, 2011
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a __dict__ descr for IOBase (closes #12878)
parent
7335e6f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
Lib/test/test_io.py
Lib/test/test_io.py
+11
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_io/iobase.c
Modules/_io/iobase.c
+14
-0
No files found.
Lib/test/test_io.py
View file @
f6f3a354
...
...
@@ -610,6 +610,17 @@ class IOTest(unittest.TestCase):
self
.
assertEqual
(
rawio
.
read
(
2
),
None
)
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
):
def
test_IOBase_finalize
(
self
):
...
...
Misc/NEWS
View file @
f6f3a354
...
...
@@ -28,6 +28,8 @@ Core and Builtins
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 #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
...
...
Modules/_io/iobase.c
View file @
f6f3a354
...
...
@@ -156,6 +156,19 @@ iobase_closed_get(PyObject *self, void *context)
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
*
_PyIOBase_check_closed
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
@@ -691,6 +704,7 @@ static PyMethodDef iobase_methods[] = {
};
static
PyGetSetDef
iobase_getset
[]
=
{
{
"__dict__"
,
iobase_get_dict
,
NULL
,
NULL
},
{
"closed"
,
(
getter
)
iobase_closed_get
,
NULL
,
NULL
},
{
NULL
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment