Skip to content

Remove Python 2 compatibility code#188

Merged
lavr merged 4 commits intomasterfrom
fix/remove-python2-compat
Mar 31, 2026
Merged

Remove Python 2 compatibility code#188
lavr merged 4 commits intomasterfrom
fix/remove-python2-compat

Conversation

@lavr
Copy link
Copy Markdown
Owner

@lavr lavr commented Mar 30, 2026

Summary

  • Remove from __future__ import from all files (35 files)
  • Simplify emails/compat/__init__.py: remove Python 2 branch, keep only Python 3 code
  • Delete unused ordereddict.py and orderedset.py
  • Remove is_py2/is_py3/is_py26/is_py34_plus version checks from code and tests
  • Remove Travis CI pypy workaround from test_loaders

-566 lines of dead code removed. All 74 tests pass on Python 3.14.

lavr added 4 commits March 31, 2026 02:37
- Remove from __future__ imports from all files
- Simplify emails/compat: remove Python 2 branch, keep only Python 3 code
- Delete unused ordereddict.py and orderedset.py
- Remove is_py2/is_py3/is_py26/is_py34_plus version checks
- Remove Travis CI pypy workaround from test_loaders
- All 74 tests pass on Python 3.14
Move to_unicode, to_native, to_bytes, formataddr to emails.utils.
Replace all compat aliases with direct stdlib imports:
- string_types -> str
- text_type -> str
- is_callable -> callable()
- urlparse -> urllib.parse
- NativeStringIO/StringIO/BytesIO -> io
- OrderedDict -> collections

Delete emails/compat package and remove from setup.py.
All 74 tests pass.
The policy test code was accidentally indented inside gen_policy()
after the return statement, making it unreachable.
@lavr lavr force-pushed the fix/remove-python2-compat branch from f783fb5 to 13908c9 Compare March 31, 2026 00:12
@lavr lavr merged commit 7d40007 into master Mar 31, 2026
7 checks passed
@lavr lavr deleted the fix/remove-python2-compat branch March 31, 2026 00:20
lavr added a commit that referenced this pull request Mar 31, 2026
Python 2 support was removed in #188, so the wheel should no longer
be tagged as py2.py3-universal.
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.

1 participant