-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-30068: add missing iter(self) in _io._IOBase.readlines when hint is present #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@zhangyangyu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @serhiy-storchaka and @ezio-melotti to be potential reviewers. |
Modules/_io/iobase.c
Outdated
@@ -666,7 +666,13 @@ _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint) | |||
} | |||
|
|||
while (1) { | |||
PyObject *line = PyIter_Next(self); | |||
PyObject *it, *line; | |||
it = PyObject_GetIter(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be outside of the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My foolish.
Misc/NEWS
Outdated
- bpo-30068: _io._IOBase.readlines will check if it's closed first when | ||
hint is present. | ||
|
||
- bpo-29692: Fixed arbitrary unchaining of RuntimeError exceptions in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better not move this entry.
@@ -665,8 +665,14 @@ _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint) | |||
return result; | |||
} | |||
|
|||
it = PyObject_GetIter(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it
is leaked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Modules/_io/iobase.c
Outdated
return result; | ||
error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: I prefer to add an empty line after return
and before a label.
No description provided.