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
Rename VerifiedHTTPSConnection #1805
Rename VerifiedHTTPSConnection #1805
Conversation
src/urllib3/connection.py
Outdated
@@ -410,6 +401,10 @@ def connect(self): | |||
) | |||
|
|||
|
|||
class VerifiedHTTPSConnection(HTTPSConnection): | |||
pass | |||
|
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 think that on the lines 423-428:
if ssl:
# Make a copy for testing.
UnverifiedHTTPSConnection = HTTPSConnection
HTTPSConnection = VerifiedHTTPSConnection
else:
HTTPSConnection = DummyConnection
We should consider the following:
- The
HTTPSConnection
class should not be shadowed by reassignment so that it is exported as is (im not sure about the use case of theDummyConnection
in the else statement) - if we are keeping
UnverifiedHTTPSConnection = HTTPSConnection
then we should also haveVerifiedHTTPSConnection = HTTPSConnection
and then removeVerifiedHTTPSConnection
class definition code.- Alternatively, a
UnverifiedHTTPSConnection
class might need to be defined just like howVerifiedHTTPSConnection
is defined.
- Alternatively, a
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 your review! Overlooked these lines. Could we delete the if statement? I like the third option you mentioned, so defining UnverifiedHTTPSConnection
like VerifiedHTTPSConnection
is simpler IMO.
I am not sure the purpose of DummyConnection
.
Let me know any thoughts.
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.
DummyConnection
seems to be used only for here.
urllib3/src/urllib3/connectionpool.py
Lines 962 to 965 in 75d2719
if not self.ConnectionCls or self.ConnectionCls is DummyConnection: | |
raise SSLError( | |
"Can't connect to HTTPS URL because the SSL module is not available." | |
) |
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'm thinking we do something like:
if ssl:
HTTPSConnection = DummyConnection
VerifiedHTTPSConnection = HTTPSConnection
so we still get the nice error if the user is running Python without an ssl
module and always get the name rebound to VerifiedHTTPSConnection
. :)
Since the UnverifiedHTTPSConnection
class was totally borked for the past ~6 months and we only received one issue on it I think we're good to remove it in the next release. 🎉 Just need to document in the changelog that there's only one HTTPSConnection object now. :)
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 @sethmlarson, Let me check the if statement. We assign DummyConnection
to HTTPSConnection
if not ssl, right? So the if statement is like this?
if not ssl:
HTTPSConnection = DummyConnection
VerifiedHTTPSConnection = HTTPSConnection
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.
You're absolutely right haha, nice catch. :)
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.
Thank you! modified the statement and added to CHANGES.rst
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 this! Almost there. :)
One thing we do need is a changelog entry for this change.
src/urllib3/connection.py
Outdated
@@ -410,6 +401,10 @@ def connect(self): | |||
) | |||
|
|||
|
|||
class VerifiedHTTPSConnection(HTTPSConnection): | |||
pass | |||
|
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'm thinking we do something like:
if ssl:
HTTPSConnection = DummyConnection
VerifiedHTTPSConnection = HTTPSConnection
so we still get the nice error if the user is running Python without an ssl
module and always get the name rebound to VerifiedHTTPSConnection
. :)
Since the UnverifiedHTTPSConnection
class was totally borked for the past ~6 months and we only received one issue on it I think we're good to remove it in the next release. 🎉 Just need to document in the changelog that there's only one HTTPSConnection object now. :)
1414651
to
f6a84b7
Compare
Thanks! I think we're going to need a |
I've made that change, thanks @pquentin for identifying. Will merge as soon as CI passes. 🎉 |
Thanks so much @kobayashi for this change! 🚀 |
Fix: #1799
Renamed
VerifiedHTTPSConnection
toHTTPSConnection
.VerifiedHTTPSConnection
is backported.