Visitar URL original
bpo-34187: _WindowsConsoleIO rises correct exception by augustogoulart · Pull Request #9922 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250624172120/https://github.com/python/cpython/pull/9922
Skip to content

bpo-34187: _WindowsConsoleIO rises correct exception #9922

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

Closed
wants to merge 6 commits into from
Closed

bpo-34187: _WindowsConsoleIO rises correct exception #9922

wants to merge 6 commits into from

Conversation

augustogoulart
Copy link
Contributor

@augustogoulart augustogoulart commented Oct 17, 2018 •

_WindowsConsoleIO implementation of fileno should raise a ValueError
instead of io.UnsupportedOperation if the internal handle value is
INVALID_HANDLE_VALUE.

Previous issue that originated issue34187:
https://bugs.python.org/issue34115

https://bugs.python.org/issue34187

_WindowsConsoleIO implementation of fileno should raise a ValueError
instead of io.UnsupportedOperation if the internal handle value is
INVALID_HANDLE_VALUE.
@augustogoulart
Copy link
Contributor Author

@taleinat

@vstinner vstinner requested a review from zooba October 24, 2018 23:52
@@ -474,16 +475,24 @@ static PyObject *
_io__WindowsConsoleIO_fileno_impl(winconsoleio *self)
/*[clinic end generated code: output=006fa74ce3b5cfbf input=079adc330ddaabe6]*/
{
if (self->fd < 0 && self->handle != INVALID_HANDLE_VALUE) {
if (self->handle == INVALID_HANDLE_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

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

This if needs curly braces.

Copy link
Contributor

@taleinat taleinat left a comment •

Choose a reason for hiding this comment

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

Thanks for making this PR!

ISTM that the potential issue in internal_close is separate from the main issue regarding fileno. I recommend removing the internal_close change from this PR, and possibly creating a separate PR for it.

Regarding the fileno issue, please add a test that reproduces the relevant bug.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

@augustogoulart
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat: please review the changes made to this pull request.

Copy link
Contributor

@taleinat taleinat left a comment

Choose a reason for hiding this comment

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

ISTM this change does more than just raise a different exception, since it also makes sure to close the file handle in a certain case. I'd like to see a test for that too.

This will need a NEWS entry; install blurb and run blurb add to create one.

Also a minor inline comment.

@@ -125,6 +125,14 @@ def test_write_empty_data(self):
with ConIO('CONOUT$', 'w') as f:
self.assertEqual(f.write(b''), 0)

def test_fileno_raises_correct_exception(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest replacing "correct_exception" with something about the file being closed.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants