Repository navigation
fix: -f runs a Python program, and an integer indexes a list - #244
Merged
Merged
Conversation
x -l python -f PROGRAM.py read the program as x-lang: print(1 + 1) answered Unbound SYMBOL 'print'. The wrapper cats the file after this bundle's entry and runs the platform's batch loop over the stream, and the entry chose a loop for a session only. The entry's last form now asks the wrapper's seam whether a file was supplied, and python-batch (python/repl.x) reads what is left of the stream as the program and runs it whole: no banner, no prompt, no echo of an expression's value, and a blank line ends nothing. A line is kept as its bytes, so a program's UTF-8 is not encoded twice. The program's standard input is put back from fd 3. An error it does not catch is on standard error, with status 1. tests/boot.sh gave -f a file of python-run forms, which is why it passed. It gives it a Python file now, with a blank line inside a block and an expression statement, and a second one that raises. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Under x -l python, a[1] on a list raised TypeError: list indices must be integers or slices, not float. So did a[-1], and [][1] in place of its IndexError. python/types.x took the float type's handle with (type-of 1.5) as it loaded, and it loads before the tower. On the dialect lang.xon declares, 1.5 is not read as a float there, so the handle was an integer's and the list subscript's float check held for every integer. The handle is bound in python/runtime-num.x, where the tower is loaded. The suite's amalgam has the tower from the start and did not show it; tests/boot.sh, which boots the declared dialect, indexes a list now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Two defects of
x -l pythonas a user runs it, neither of which the suite could show. Two commits.1.
-fruns a Python programx -l python -f PROGRAM.pyread the program as x-lang:The wrapper cats the file after this bundle's entry and runs the platform's batch loop over the stream. The entry chose a loop for a session only.
run.x: the last form asks the wrapper's seam whether a file was supplied, and callspython-batch.python/repl.x,python-batch: reads what is left of the stream as the program and runs it whole. No banner, no prompt, no echo of an expression's value; a blank line ends nothing.A file of
(python-run ...)forms given with-fis no longer read:-fmeans Python.tests/boot.shwas the one caller found.2. An integer index on a list
Under
x -l python:So did
a[-1], and[][1]in place of itsIndexError. Slices and tuples were not affected.python/types.xtook the float type's handle with(type-of 1.5)as it loaded, and it loads before the tower. On the dialectlang.xondeclares,1.5is not read as a float there, so the handle was an integer's. The handle is bound inpython/runtime-num.xnow, where the tower is loaded.Why the suite passed
1.5is a float from the start.tests/boot.sh, which boots the declared dialect, gave-fa file ofpython-runforms and indexed no list.tests/boot.shnow gives-fa Python file with a blank line inside a block, an expression statement and a list index, and a second file that raises.Verified
On v0.59.0:
Seventeen Python programs through
-ffrom a state image, each compared with what CPython prints (the card draft that found both):Not verified
__file__is not set and an import looks in the working directory, not beside the program: the wrapper cats the file and its name does not reach the bundle.raise SystemExit(N)ends with status 0, aspython-runhas it.-fstill gets the banner and the prompts.🤖 Generated with Claude Code