Skip to content

Drop Python 2#1693

Merged
davidism merged 14 commits into
pallets:masterfrom
pgjones:no_py2
Mar 17, 2020
Merged

Drop Python 2#1693
davidism merged 14 commits into
pallets:masterfrom
pgjones:no_py2

Conversation

@pgjones
Copy link
Copy Markdown
Member

@pgjones pgjones commented Jan 6, 2020

I'm not sure what release this will be in, 1, 1.1, 2?

@davidism
Copy link
Copy Markdown
Member

davidism commented Jan 6, 2020

Well, I've only been looking forward to doing this for 2 years, but ok, you get the pr 😉

This will be in 2, so I can't merge it until after 1 is released.

Comment thread src/werkzeug/_internal.py Outdated
Comment thread src/werkzeug/_internal.py Outdated
Comment thread src/werkzeug/_internal.py Outdated
Comment thread src/werkzeug/_reloader.py Outdated
Comment thread src/werkzeug/_compat.py Outdated
Comment thread tests/test_datastructures.py Outdated
@davidism
Copy link
Copy Markdown
Member

davidism commented Jan 6, 2020

Since we're supporting 3.6+, we can use f-strings everywhere. Can drop u prefix.

I'd like to investigate moving away from supporting both bytes and text as arguments everywhere, as Python 3 should have much clearer delineation between where those types should be present. In the past there was an issue about Pallets being much slower after the 2/3 compat transition, that was caused by the constant type checking and conversion that had to be added. This can be a separate ticket though.

@and-semakin

This comment has been minimized.

@davidism

This comment has been minimized.

@davidism davidism force-pushed the no_py2 branch 5 times, most recently from 183cd6f to e87b963 Compare March 16, 2020 16:32
@davidism davidism added this to the 2.0.0 milestone Mar 16, 2020
@davidism
Copy link
Copy Markdown
Member

I did some cleanup of the helpers we kept from _compat.

Replaced to_native with to_str, or removed the call completely where possible. I only looked at uses of to_native, there are plenty of places where to_str or to_bytes could be removed. There's also inconsistency in whether a charset is passed to them, I feel like it should default to utf-8 instead of the system encoding, since otherwise things are just working by accident.

Removed reraise, as there's only one syntax we need to support now.

Removed the strict_eq test helper, as it was only for dealing with Python 2 casing unicode to str during comparisons.

@davidism

This comment has been minimized.

pgjones and others added 14 commits March 17, 2020 08:08
This removes the official support for 2.7 without making any code
changes. It allows for code changes to be made.
This is possible now that Python 2 is not supported. The code that is
still required has been moved to the _internal module and renamed with
a leading `_` as per the other functions. As this change is targeting
Werkzeug 2.0 the compatibility with 3.5 is dropped, 2.0 will be Python
3.6+.
The latter is clearer in a Python3 context.
This has replaced a lot of Python2 idioms with Python3.6 idioms (see
https://github.com/asottile/pyupgrade).
serving._SSLContext wrapper
SharedDataMiddleware loader compat
deprecate http decode/encode_keys argument
use of detect_utf_encoding for json
code paths with Python < 3.6 comments
except ImportError fallbacks
sys.version_info checks
use platform.system()
mentions of Python 2 compat in some docs and comments
remove to_native call where possible
rename normalize_string_tuple to check_str_tuple
rename make_literal_wrapper to make_encode_wrapper
@davidism davidism merged commit 6868ede into pallets:master Mar 17, 2020
jab added a commit to jab/werkzeug that referenced this pull request Mar 20, 2020
jab added a commit to jab/werkzeug that referenced this pull request Mar 20, 2020
jab added a commit to jab/werkzeug that referenced this pull request Mar 21, 2020
Python 2 support was dropped in pallets#1693.

* Remove superfluous __ne__ and __cmp__ implementations.
* Use no-arg super() rather than 2-arg super(...).
jab added a commit to jab/werkzeug that referenced this pull request Mar 21, 2020
Python 2 support was dropped in pallets#1693.

* Remove superfluous __ne__ and __cmp__ implementations.
* Use no-arg super() rather than 2-arg super(...).

Also improve associated tests.
jab added a commit to jab/werkzeug that referenced this pull request Mar 21, 2020
Python 2 support was dropped in pallets#1693.

* Remove superfluous __ne__ and __cmp__ implementations.
* Use no-arg super() rather than 2-arg super(...).

Also improve associated tests.
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
@pgjones pgjones deleted the no_py2 branch June 11, 2022 09:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants