Updated syntax to Python 3 for improved compatibility on MacOS.#126
Open
andrewpking wants to merge 1 commit into
Open
Updated syntax to Python 3 for improved compatibility on MacOS.#126andrewpking wants to merge 1 commit into
andrewpking wants to merge 1 commit into
Conversation
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.
Port brigadier to Python 3
Summary
This PR updates
brigadierto be compatible with Python 3. The original script was written for Python 2, which has reached end-of-life and is no longer available via Homebrew or most modern package managers. These changes allow brigadier to run under Python 3 without requiring any legacy Python installation.The conversion was initiated using the
2to3migration tool, with additional manual fixes applied to address API removals and type incompatibilities introduced in Python 3.Changes
Print statements →
print()functionsPython 3 requires
printto be called as a function. All bareprintstatements have been updated accordingly.Before:
After:
plistlib.readPlistFromString()→plistlib.loads()readPlistFromStringwas deprecated in Python 3.4 and removed in Python 3.9. Replaced with the modernplistlib.loads().Before:
After:
plistlib.readPlist()→plistlib.load()Similarly,
readPlistwas removed in Python 3.9. Replaced withplistlib.load(), which requires a binary file object.Before:
After:
urllib2→urllib.requesturllib2does not exist in Python 3. Allurllib2.urlopen()calls have been replaced withurllib.request.urlopen().Before:
After:
Bytes vs string type handling for HTTP responses
In Python 3,
urllib.request.urlopen().read()returnsbytesrather than astr. Passing a bytes object tore.search()with a string pattern raises aTypeError. All HTTP response bodies used with regex are now decoded to UTF-8 strings.Before:
After:
Invalid regex escape sequences
2to3surfacedSyntaxWarningfor invalid escape sequences in regex strings that will become errors in future Python versions. These have been updated to use raw strings.Before:
After:
Testing
Tested on:
MacBookAir7,2(mid-2015 MacBook Air, 13-inch)Dependencies
The
futurepackage is no longer required. All changes use Python 3 stdlib only.Notes
2to3tool was used as a starting point but was not sufficient on its own — several runtime errors required manual fixes post-conversion, particularly aroundplistlibAPI removals and bytes/string type handling.