Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7589b71

Browse files
committed
I_getattr(),
O_getattr(): Added read-only access to the closed attribute, based on comment from Michael Scharf <[email protected]>.
1 parent 7f1d3aa commit 7589b71

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Modules/cStringIO.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,12 @@ O_dealloc(Oobject *self) {
389389

390390
static PyObject *
391391
O_getattr(Oobject *self, char *name) {
392-
if (strcmp(name, "softspace") == 0) {
392+
if (name[0] == 's' && strcmp(name, "softspace") == 0) {
393393
return PyInt_FromLong(self->softspace);
394394
}
395+
else if (name[0] == 'c' && strcmp(name, "closed") == 0) {
396+
return PyInt_FromLong(self->closed);
397+
}
395398
return Py_FindMethod(O_methods, (PyObject *)self, name);
396399
}
397400

@@ -496,6 +499,9 @@ I_dealloc(Iobject *self) {
496499

497500
static PyObject *
498501
I_getattr(Iobject *self, char *name) {
502+
if (name[0] == 'c' && strcmp(name,"closed") == 0) {
503+
return PyInt_FromLong(self->closed);
504+
}
499505
return Py_FindMethod(I_methods, (PyObject *)self, name);
500506
}
501507

0 commit comments

Comments
 (0)