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 Spitfire to Python 3
Description
This PR ports the entire
spitfireproject to Python 3. It addresses syntax changes, standard library reorganization, unicode/bytes handling, and C extension APIs.Changes
Vendored Libraries
third_party/yapps2:printstatements to functions.except E as v).stringmodule functions andapply().StringIOimports withio.Core Spitfire
print(),exec(),raise.basestringwithstr.unicode()withstr().iteritems->items).optimizer.py: Fixed iterator mutation bug by creating list copies of dictionary items during iteration.util.py/codegen.py: Updated file opening modes torb/wbto correctly handle binary data/encoding, ensuring strict bytes/str separation compliance.import osinoptimizer.py.Scripts
scripts/spitfire-compile: Updated for Python 3 I/O and exception handling.scripts/crunner.py:cStringIOwithio.sys.path.C Extensions
_udn.c: Ported to Python 3 C API (module initialization,PyUnicodeinstead ofPyString)._template.c: Ported to Python 3 C API._baked.c: Disabled insetup.py. This extension relies deeply on Python 2PyStringObjectinternals. The Python fallback (spitfire/runtime/baked.py) is fully functional and used instead.Tests
tests/test-hoist-conditional-loop-optimization-3.txtto use$range()instead of$xrange().tests/output/to match Python 3 exception messages andrepr()output (e.g., removinguprefix).Verification
Ran
make testwhich executesunittestdiscovery andspitfire-compileintegration tests.--preserve-optional-whitespacetests.