-
-
Notifications
You must be signed in to change notification settings - Fork 22
Fix test_connect_ipv6_addr. #75
Fix test_connect_ipv6_addr. #75
Conversation
Codecov Report
@@ Coverage Diff @@
## bleach-spike #75 +/- ##
================================================
+ Coverage 98.36% 98.37% +<.01%
================================================
Files 30 30
Lines 1901 1905 +4
================================================
+ Hits 1870 1874 +4
Misses 31 31
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## bleach-spike #75 +/- ##
================================================
+ Coverage 98.36% 98.37% +<.01%
================================================
Files 30 30
Lines 1901 1905 +4
================================================
+ Hits 1870 1874 +4
Misses 31 31
|
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.
Looks like a good approach to me!
This is one of those classic ones...
Writing the patch: 10 minutes
Figuring out which patch to write: 10 hours
socket.inet_pton(socket.AF_INET6, host) | ||
target = "[%s]:%d" % (host, port) | ||
except OSError: | ||
target = "%s:%d" % (host, port) |
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.
I'd probably write it like:
try:
socket.inet_pton(socket.AF_INET6, host)
except OSError:
# Not a raw IPv6 address
target = "%s:%d" % (host, port)
else:
# raw IPv6 address
target = "[%s]:%d" % (host, port)
It doesn't make a big difference here, but it's a good habit in cases like this to only put the minimal stuff inside the try
block, to make sure you don't catch any unexpected exceptions by accident.
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 it seem more readable to me.
Hmm. I bet we're also going to need a similar check somewhere to set up the |
I will look where we need to set-up such check for |
That does not exist at all in the urllib3 tests currently, so maybe we can address this in a future pull request? I opened #87 to this effect |
I have added a check in for ipv6 host in
_build_tunnel_request
and accordingly modify the target, is there a better way ?