-
-
Notifications
You must be signed in to change notification settings - Fork 745
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
Support AF_INET6 address family #383
Conversation
This PR should resolve the issue stated here encode#313 . As stated here https://docs.python.org/2/library/socket.html#socket.AF_INET6, "For AF_INET6 address family, a four-tuple (host, port, flowinfo, scopeid) is used", so there should be no possible problems with type conversion on row 12 of this PR. So I think, that there is no need for additional tests, already existing should be enough to cover this.
Gotcha. Test cases currently failing, when looking up the “socket” extra info - not looked into it beyond that yet. |
It seems to me, that MockTransport in tests misses 'socket' attribute. Here is a documentation for BaseTransport (which is being mocked in tests, as i understand) https://docs.python.org/3/library/asyncio-protocol.html#asyncio.BaseTransport.get_extra_info - 'socket' is also an attribute among with sockname, peername and sslcontext . I guess, we need to fix MockTransport in tests. Should we do it in this pr or create another? |
Fixing it in this PR would be fine. However we ought to be a bit cautious about which items might or might not be present with get_extra_info. If we can fallback gracefully when particular items are not included then we should do that. |
Like, first try to get 'socket', then, if it is not present, just return peername/sockname? |
@Yolley Exactly, yes. I'd also suggest leaving the existing layout of the def get_local_addr(transport):
info = transport.get_extra_info("socket"). # Only these lines changed
if info is not None: # Only these lines changed
return info.getsockname() # Only these lines changed
info = transport.get_extra_info("sockname")
if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:
return (str(info[0]), int(info[1]))
return None |
I made changes in this PR like you suggested, but we still need to make some changes in MockTransport, we need to change logic of method def get_extra_info(self, key):
return {
"sockname": self.sockname,
"peername": self.peername,
"sslcontext": self.sslcontext,
}.get(key) |
Yup, your suggestion there looks correct to me. |
So, i fixed MockTransport, now it uses |
Running |
Yep, it seems, that black follows pep8 line of length (which is questionable in 2019, but it is still an approved standart, so). Reformatted test_utils.py |
Released as 0.8.3. Good stuff! 👍 |
Closes #313 .
As stated here https://docs.python.org/2/library/socket.html#socket.AF_INET6, "For AF_INET6 address family, a four-tuple (host, port, flowinfo, scopeid) is used", so there should be no possible problems with type conversion on row 12 of this PR. So I think, that there is no need for additional tests, already existing should be enough to cover this.