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

Remove six and other Python 2+3 compatibility code #28776

Open
foolip opened this issue May 1, 2021 · 2 comments
Open

Remove six and other Python 2+3 compatibility code #28776

foolip opened this issue May 1, 2021 · 2 comments
Labels

Comments

@foolip
Copy link
Member

foolip commented May 1, 2021

After https://github.com/web-platform-tests/rfcs/blob/master/rfcs/py_3.md there's some cleanup is possible. Most obvious is the use of six, but there are other things like checking sys.version_info as well.

This is a tracking issue just to link them together for discoverability after the fact.

@foolip foolip added the python3 label May 1, 2021
foolip added a commit that referenced this issue May 1, 2021
We can assume Python 3.6 or later.

Part of #28776.
foolip added a commit that referenced this issue May 3, 2021
We can assume Python 3.6 or later.

Part of #28776.
foolip added a commit that referenced this issue May 3, 2021
These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Part of #28776.
@foolip
Copy link
Member Author

foolip commented May 3, 2021

PRs done soon before I filed this issue: #28735 + #28740 + #28747 + #28748

foolip added a commit that referenced this issue May 3, 2021
pyvirtualdisplay would perhaps have been nice, but the tests just run on
the real display currently.

Part of #28776.
foolip added a commit that referenced this issue May 3, 2021
These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Since no use of six remains in tools/wptserve/, it's removed as a
dependency in wptserve's setup.py.

Part of #28776.
foolip added a commit that referenced this issue May 3, 2021
These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Since no use of six remains in tools/wptserve/, it's removed as a
dependency in wptserve's setup.py.

Part of #28776.
foolip added a commit that referenced this issue May 4, 2021
In Python 3, it's an alias for io.BytesIO:
https://six.readthedocs.io/#six.BytesIO

Part of #28776.
foolip added a commit that referenced this issue May 4, 2021
foolip added a commit that referenced this issue May 5, 2021
These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Since no use of six remains in tools/wptserve/, it's removed as a
dependency in wptserve's setup.py.

Part of #28776.
jgraham pushed a commit that referenced this issue May 5, 2021
pyvirtualdisplay would perhaps have been nice, but the tests just run on
the real display currently.

Part of #28776.
foolip added a commit that referenced this issue May 5, 2021
os.environ always uses str on Python 3, there's a new os.environb for a
bytes version, which isn't supported on Windows:
https://docs.python.org/3/library/os.html#os.environ
https://docs.python.org/3/library/os.html#os.environb

Simply trust os.environ to be a dict[str, str], and simplify the
openssl.py code to something more like in GeckoDriverServer and
elsewhere:
https://github.com/web-platform-tests/wpt/blob/302039ac7c43c71bc5389104c81871b81d6cc9e0/tools/wptrunner/wptrunner/webdriver_server.py#L187-L193

Part of #28776.
foolip added a commit that referenced this issue May 6, 2021
foolip added a commit that referenced this issue May 6, 2021
These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Since no use of six remains in tools/wptserve/, it's removed as a
dependency in wptserve's setup.py.

Part of #28776.
@foolip
Copy link
Member Author

foolip commented May 10, 2021

There are pull requests up for all remaining use of six now, with #28935 still a draft. I'd like to enably mypy for that code first to trust the change more.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…ypes/text_type, a=testonly

Automatic update from web-platform-tests
Remove use of six.integer_types/string_types/text_type (#28789)

These are constants corresponding to just int/str/str in Python 3:
https://six.readthedocs.io/#constants

This is simple search-replace with the exception of
resources/test/conftest.py, where element.text is already a string. If
it were None or bytes, then JSON parsing would fail anyway.

In service-workers/cache-storage/resources/vary.py, the reason why
str(cookie_vary) works was non-obvious. Correct the documentation in
tools/wptserve/wptserve/request.py to show that the cookie_vary value
would be a CookieValue, not a binary string.

Since no use of six remains in tools/wptserve/, it's removed as a
dependency in wptserve's setup.py.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 3d43b6e82565100055bf160373a10a2388472cfe
wpt-pr: 28789
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…r (never bytes), a=testonly

Automatic update from web-platform-tests
Rely on argparse argument types being str (never bytes) (#28921)

Tweak the test to no longer test bytes input, but do test that a
trailing newline is stripped, which could matter.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: ea77e651548088e996ea1c50b5acf7ff4c66c078
wpt-pr: 28921
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…hunker, a=testonly

Automatic update from web-platform-tests
Remove use of six.ensure_binary in HashChunker (#28923)

Encoding as iso-8859-1 would be faster and could never fail, but stick
with the default utf8 encoding to not change the existing order.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 208e86d5df6cb4c197e85e46f404a71f86bbc834
wpt-pr: 28923
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…testonly

Automatic update from web-platform-tests
Tear down the load_and_update facade (#28922)

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 3bdf00edecac0b70aaac05797d73d9171140074d
wpt-pr: 28922
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
… bytes), a=testonly

Automatic update from web-platform-tests
Rely on os.path.* returning strings (not bytes) (#28926)

Part of web-platform-tests/wpt#28776.
--

wpt-commits: d25f59487c39042b3d2ee9309f8cc740e48236da
wpt-pr: 28926
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
Automatic update from web-platform-tests
Remove use of six.reraise (#28887)

Implementation of this for Python 3:
https://github.com/web-platform-tests/wpt/blob/aa9b753e75bb0c7de5a05277c91cef3a7a7348e4/tools/third_party/six/six.py#L697-L706

Simplifying that step by step leads to the new code.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 402658bca3671639b2873ea4834d83af815e924b
wpt-pr: 28887
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…ndary, a=testonly

Automatic update from web-platform-tests
Clean up around PathFilter str/bytes boundary (#28927)

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 70f4ba37b49c4b4f09d2a85843870e502e532afc
wpt-pr: 28927
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 14, 2021
…() for screenshot decoding, a=testonly

Automatic update from web-platform-tests
Replace six.ensure_str with just .decode() for screenshot decoding (#28930)

Part of web-platform-tests/wpt#28776.

See also web-platform-tests/wpt#28929.
--

wpt-commits: 9c9f86c4a4ca0c5842a046d7dad2525649f37ae1
wpt-pr: 28930
foolip added a commit that referenced this issue Sep 10, 2021
ConditionalValue.set_value was by all appearances unused, with no other
matches for "set_value" in the code base.

Part of #28776.
foolip added a commit that referenced this issue Mar 25, 2022
ConditionalValue.set_value was by all appearances unused, with no other
matches for "set_value" in the code base.

Part of #28776.
foolip added a commit to foolip/wpt that referenced this issue Mar 31, 2022
This is by all appearances unused, with no other matches for "set_value"
in the code base.

This removal brings along with it a use of six.ensure_text.

Part of web-platform-tests#28776.
foolip added a commit to foolip/wpt that referenced this issue Mar 31, 2022
This is by all appearances unused, with no other matches for "set_value"
in the code base.

This removal brings along with it a use of six.ensure_text.

Part of web-platform-tests#28776.
foolip added a commit that referenced this issue Mar 31, 2022
This is by all appearances unused, with no other matches for "set_value"
in the code base.

This removal brings along with it a use of six.ensure_text.

Part of #28776.
foolip added a commit that referenced this issue Mar 31, 2022
ConditionalValue.set_value was by all appearances unused, with no other
matches for "set_value" in the code base.

Part of #28776.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Apr 11, 2022
…, a=testonly

Automatic update from web-platform-tests
Remove unused ConditionalValue.set_value (#33444)

This is by all appearances unused, with no other matches for "set_value"
in the code base.

This removal brings along with it a use of six.ensure_text.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 8678fd4c89c2efe2440f82a0a172dcafff462ff6
wpt-pr: 33444
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Apr 14, 2022
…, a=testonly

Automatic update from web-platform-tests
Remove unused ConditionalValue.set_value (#33444)

This is by all appearances unused, with no other matches for "set_value"
in the code base.

This removal brings along with it a use of six.ensure_text.

Part of web-platform-tests/wpt#28776.
--

wpt-commits: 8678fd4c89c2efe2440f82a0a172dcafff462ff6
wpt-pr: 33444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant