Skip to content

bpo-34187: _WindowsConsoleIO rises correct exception#9922

Closed
augustogoulart wants to merge 6 commits intopython:mainfrom
augustogoulart:bpo34187
Closed

bpo-34187: _WindowsConsoleIO rises correct exception#9922
augustogoulart wants to merge 6 commits intopython:mainfrom
augustogoulart:bpo34187

Conversation

@augustogoulart
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

@taleinat

@vstinner vstinner requested a review from zooba October 24, 2018 23:52
Comment thread Modules/_io/winconsoleio.c Outdated
/*[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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link
Copy Markdown

Thanks for making the requested changes!

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

Copy link
Copy Markdown
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.

with ConIO('CONOUT$', 'w') as f:
self.assertEqual(f.write(b''), 0)

def test_fileno_raises_correct_exception(self):
Copy link
Copy Markdown
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
Copy Markdown

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