Skip to content

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

Merged
merged 6 commits into from
Apr 15, 2017

Conversation

zhangyangyu
Copy link
Member

No description provided.

@zhangyangyu zhangyangyu added type-bug An unexpected behavior, bug, or error needs backport to 2.7 labels Apr 14, 2017
@mention-bot
Copy link

@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.

@@ -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);
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is leaked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return result;
error:
Copy link
Member

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.

@zhangyangyu zhangyangyu merged commit 026435c into python:master Apr 15, 2017
@zhangyangyu zhangyangyu deleted the bpo-30068 branch April 15, 2017 04:47
zhangyangyu added a commit to zhangyangyu/cpython that referenced this pull request Apr 15, 2017
zhangyangyu added a commit to zhangyangyu/cpython that referenced this pull request Apr 15, 2017
zhangyangyu added a commit to zhangyangyu/cpython that referenced this pull request Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants