-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Drop support for EOL Python 2.6 #1429
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1429 +/- ##
======================================
Coverage 100% 100%
======================================
Files 21 21
Lines 1792 1790 -2
======================================
- Hits 1792 1790 -2
Continue to review full report at Codecov.
|
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 looks like a great start. Could you address a few of my comments?
src/urllib3/util/ssl_.py
Outdated
supports_set_ciphers = ((2, 7) <= sys.version_info < (3,) or | ||
(3, 2) <= sys.version_info) | ||
|
||
class SSLContext(object): # Platform-specific: Python 2 |
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.
Can we add back a supports_set_ciphers = True
here? Just for backwards compatibility.
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.
Reverted.
src/urllib3/connection.py
Outdated
@@ -108,21 +104,10 @@ def __init__(self, *args, **kw): | |||
if six.PY3: # Python 3 | |||
kw.pop('strict', None) | |||
|
|||
# Pre-set source_address in case we have an older Python like 2.6. | |||
self.source_address = kw.get('source_address') |
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 we should keep this attribute on the HTTPConnection
object, might be being used by others.
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.
Kept.
Could you comment on how you found the occurrences for these optimizations? Was it a manual effort or is there a tool for the unittest improvements? |
Sure, for the set/dict/list literals, I used the code inspection (Code > Inspect Code...) in PyCharm (they have a lightweight Community edition and also free licences for the full version for open source projects). For the unit tests, I used the script at https://github.com/hugovk/upgrade-unittest which is just some sed commands, not a full AST parser, so you need to check the changes. There's also the https://github.com/jparise/flake8-assertive plugin, which I've just run and found some others which I've updated. |
I'm approving these changes, just got to let CI pass now. :) |
Thanks for doing this! 🎉 |
As a quick note, we dropped support for 2.6 but haven’t merged the removal changes into master since that would be a breaking change for Requests 2.X. We can probably go ahead and drop it, but we’ll need to make an announcement that it breaks now. |
You're welcome! |
Thank you again @hugovk, that was a quick and high-quality PR. :) Would you be interested in working on urllib3 async support with us? |
Thanks, happy to help out, but I'm not yet really familiar with async. |
Also @hugovk since you did the bulk of this work could you add a changelog entry for dropping Python 2.6 and add yourself to contributors list if you're not already there. |
@SethMichaelLarson Done! Please see #1431. |
@hugovk There are many ways to help even if you're not familiar with async yet! Removing Python 2.6 support was one of those things. :) Another helpful thing to do is to improve the setup.py script: python-trio/trio#567 (comment). There are many things to do but they are not documented yet. Feel free to open an issue in https://github.com/python-trio/urllib3/ or send me an email at [email protected] if anything is unclear. But no pressure! |
For #883.
Requests and pip have already dropped Python 2.6.
This PR removes support for it, removes redundant code, and also does some modernising to use newer Python features.