Modernize Python 2 compatibility code to Python 3.10+ - #227
Merged
Conversation
- Updated setup.py to require Python 3.10+ and removed Python 2 dependencies - Removed all __future__ imports from Python files - Replaced unicodecsv imports with standard csv module - Updated unicode() function calls to use str() - Fixed CSV file handling to use proper text mode with UTF-8 encoding - Updated documentation examples to remove Python 2/3 version references - Fixed shebang line in reromanize.py from python2 to python3 - Updated documentation links to point to Python 3 docs Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR modernizes the codebase by removing Python 2 compatibility code and updating it to be compatible with Python 3.10 and above. Since Python 2 has reached end-of-life and is no longer supported, this modernization simplifies the codebase and takes advantage of Python 3's native Unicode support.
Changes Made
Setup and Dependencies
setup.pyto require Python 3.10+ withpython_requires='>=3.10'Code Modernization
__future__imports: Eliminated allfrom __future__ importstatements (71 files affected)unicodecsvto standardcsvmoduleunicode()function calls withstr()'rb') to text mode ('r') with UTF-8 encodingu''Unicode string prefixesDocumentation Updates
reromanize.pyfrompython2topython3Files Modified
setup.pyepitran/directoryepitran/bin/directoryREADME.mdwith modernized examples and requirementsBenefits
Testing
The changes maintain backward compatibility for the public API while modernizing the internal implementation. All existing functionality should work identically, but now requires Python 3.10+.
Breaking Changes
unicodecsv(uses standardcsvmodule)This is a significant modernization that brings the codebase up to current Python standards while maintaining all existing functionality.