Skip to content
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

Merged

Conversation

kobayashi
Copy link
Contributor

Fix: #1799
Renamed VerifiedHTTPSConnection to HTTPSConnection. VerifiedHTTPSConnection is backported.

@@ -410,6 +401,10 @@ def connect(self):
)


class VerifiedHTTPSConnection(HTTPSConnection):
pass

Copy link

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 the DummyConnection in the else statement)
  • if we are keeping UnverifiedHTTPSConnection = HTTPSConnection then we should also have VerifiedHTTPSConnection = HTTPSConnection and then remove VerifiedHTTPSConnection class definition code.
    • Alternatively, a UnverifiedHTTPSConnection class might need to be defined just like how VerifiedHTTPSConnection is defined.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
raise SSLError(
"Can't connect to HTTPS URL because the SSL module is not available."
)

Copy link
Member

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. :)

Copy link
Contributor Author

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

Copy link
Member

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. :)

Copy link
Contributor Author

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

Copy link
Member

@sethmlarson sethmlarson 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 this! Almost there. :)

One thing we do need is a changelog entry for this change.

@@ -410,6 +401,10 @@ def connect(self):
)


class VerifiedHTTPSConnection(HTTPSConnection):
pass

Copy link
Member

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. :)

@kobayashi kobayashi force-pushed the 1799-rename_verifiedhhtpsconnection branch from 1414651 to f6a84b7 Compare February 28, 2020 04:49
@pquentin
Copy link
Member

Thanks! I think we're going to need a # NOQA comment to silence the F811 flake8 warnings: https://travis-ci.org/urllib3/urllib3/jobs/656104926

@sethmlarson
Copy link
Member

I've made that change, thanks @pquentin for identifying. Will merge as soon as CI passes. 🎉

@sethmlarson sethmlarson merged commit 33a29c5 into urllib3:master Feb 29, 2020
@sethmlarson
Copy link
Member

Thanks so much @kobayashi for this change! 🚀

Dobatymo pushed a commit to Dobatymo/urllib3 that referenced this pull request Mar 16, 2022
vEpiphyte added a commit to vertexproject/vcrpy that referenced this pull request May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename VerifiedHTTPSConnection to HTTPSConnection
4 participants