-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-28369: Enhance transport socket check in add_reader/writer #4365
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
|
@asvetlov Andrew, could you please take a look at this one? |
asvetlov
left a comment
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.
Thanks for PR.
Please fix notes.
I suggest installing codecov browser extension: https://docs.codecov.io/v4.3.6/docs/browser-extension
You'll see uncovered red lines just in Files changed tab on gihub.
| self.call_exception_handler(context) | ||
|
|
||
| def _ensure_fd_no_transport(self, fd): | ||
| fileno = fd |
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.
Please not make a new fileno local variable but reuse fd in the rest of function -- like selectors._fileobj_to_fd does.
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.
fd is used later in this function to format a better error message. This is not a copy/paste of selectors._fileobj_to_fd.
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.
Got it, sorry.
Lib/asyncio/selector_events.py
Outdated
| try: | ||
| fileno = int(fileno.fileno()) | ||
| except (AttributeError, TypeError, ValueError): | ||
| # This code matches `selectors._fileobj_to_fd` function. |
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.
Please avoid backticks -- without them the comment is still pretty clean.
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.
Removed, but this is a very personal preference -- for me it was easier to read that comment with backticks/quotes.
Lib/asyncio/test_utils.py
Outdated
| try: | ||
| fd = int(fd.fileno()) | ||
| except (AttributeError, TypeError, ValueError): | ||
| # This code matches `selectors._fileobj_to_fd` function. |
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.
Avoid backticks.
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.
Why?
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.
@1st1 I hate any complex markup in comments, selectors._fileobj_to_fd without backticks is still pretty readable and understandable.
This is just my opinion.
But if you want to keep them -- I can live with it. Very minor thing about a taste.
| fileno = int(fileno.fileno()) | ||
| except (AttributeError, TypeError, ValueError): | ||
| # This code matches `selectors._fileobj_to_fd` function. | ||
| raise ValueError("Invalid file object: " |
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.
Not covered by tests
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.
Added a functional test for this.
| def _ensure_fd_no_transport(self, fd): | ||
| if not isinstance(fd, int): | ||
| try: | ||
| fd = int(fd.fileno()) |
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.
Not covered
| fd = int(fd.fileno()) | ||
| except (AttributeError, TypeError, ValueError): | ||
| # This code matches `selectors._fileobj_to_fd` function. | ||
| raise ValueError("Invalid file object: " |
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.
Not covered.
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 won't be covered as it's test_utils' test loop. There's no point in covering it.
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.
Maybe let's add # pragma: no cover comment for except clause?
It increases formal coverage level at least (:
|
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 |
|
Thanks for making the requested changes! @asvetlov: please review the changes made to this pull request. |
asvetlov
left a comment
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.
Sorry for my censoriousness.
|
Thanks, Andrew! |
https://bugs.python.org/issue28369
Original PR python/asyncio#420 missed the fact that
loop.add_readerandloop.add_writeraccept file-like objects in addition to int FDs.