* Run gc_collect ten times per benchmark iteration
Assisted-by: Grok:4.6
* Reuse the prebuilt rustpython for CI whats_left
whats_left was invoking cargo build --release without threading,
so the snippets job rebuilt the interpreter after the earlier
release build.
Assisted-by: Grok:4.6
* Split CI cargo run and test into build then execute
Assisted-by: Grok:4.6
* Compile doctests in the CI build step
cargo test --no-run skips doctests, so rustdoc compilation
was still happening in the run step.
Assisted-by: Grok:4.6
* Drop cron-ci.yaml from this PR
A pull_request path filter matches the whole PR, so every
push was starting the periodic benchmark and coverage jobs.
Assisted-by: Grok:4.6
* Run doctests in their own CI step
cargo test --doc --no-run is rejected, so doctests cannot
be compiled without also executing them.
Assisted-by: Grok:4.6
* Do not run benchmark targets in rust tests
--all-targets includes Criterion benches, which cargo test
does not run by default.
Assisted-by: Grok:4.6
* Classify incomplete input from tokenizer EOF flags
Treat exec's implicit newline, single-quoted f/t-strings, blank
single input, and unclosed field braces the way E_EOF, E_EOFS,
and E_EOLS do.
Assisted-by: Grok:4.6
* address review: lambda defaults, unicode prefixes, comments
Keep lambda parameter defaults and Unicode identifiers continuable,
and report comment-only single input as SyntaxError.
Assisted-by: Grok:4.6
Point ruff_python_parser, ruff_python_ast, ruff_text_size and
ruff_source_file at the published rustpython-ruff_* 0.16.5 crates
instead of the git tag. Update chacha20 to 0.10.2 because 0.10.1 is
yanked.
Assisted-by: Claude Code:claude-fable-5-1
* Keep escaped generator frames and wrap asyncgen throw
Mark gi_frame/cr_frame/ag_frame as escaped so locals survive
deallocation, and let frame.clear() drop those locals after
owner finalize. Route throw() through finalize_send_result so
StopAsyncIteration is wrapped like send(). Add ag_suspended
and drop never-started frame locals on close().
Assisted-by: Grok:grok-4.6
* Store escaped on iframe; skip unused cold alloc
Keep the escaped flag on InterpreterFrame so mark_escaped
and has_escaped do not allocate FrameColdData. Clear optional
cold fields only when they exist. Transfer frame owner in
close() the same way send/throw already do.
Assisted-by: Grok:grok-4.6
* Replace escaped flag with take_ownership
gi_frame returns the frame object. Close uses a uniquely-referenced
check to clear locals or take_ownership onto a husk. frame.clear()
finalizes a generator-owned frame and only clears FRAME_OBJECT
frames. close() leaves the generator suspended when it yields on
GeneratorExit.
Assisted-by: Grok:grok-4.6
* Drop frame mutex; steal frame_obj atomically
take_ownership stores None in an atomic slot instead of locking
and swapping a husk. gi_code reads the kept executable. Resume
exclusivity stays on the running claim.
Assisted-by: Grok:grok-4.6
* Remove the deprecated rustpython-compiler-source crate
Nothing in the workspace depends on it, and its version was pinned to
0.4.1+deprecated, which is already on crates.io. Drop the crate, its
Cargo.lock entry, and the mentions in host_env_proposal.md.
Assisted-by: Claude Code:claude-fable-5-1
* ci: drop the rustpython-compiler-source exclusions
The crate no longer exists in the workspace.
Assisted-by: Claude Code:claude-fable-5-1
* venvlauncher: mark the crate as not publishable
It is a Windows-only binary that venv copies out of the installation,
not a crates.io dependency.
Assisted-by: Claude Code:claude-fable-5-1
* Add script to run upstream pyperformance against RustPython
pyperformance can't be installed as-is on RustPython since pyperf hard-depends
on psutil, a C extension RustPython cannot build or load (no CPython C-API /
extension-module support). Since pyperf already disables psutil usage on
interpreters reporting Py_GIL_DISABLED=1 (which RustPython does, having no
GIL), a functionality-free pure-Python psutil stub is enough to satisfy pip's
dependency resolution and unblock any pure-Python benchmark.
scripts/pyperformance/run_all.py drives pyperformance (under a host CPython
venv) with RustPython as the --python target, installs the stub via
PIP_FIND_LINKS + --inherit-environ, and catalogs pass/fail/timeout per
benchmark with an automatic failure classifier (C-extension build blocked vs.
a genuine exception raised by the benchmark itself).
Assisted-by: Claude Code:claude-sonnet-5
* pyperformance: support targeting any Python and comparing catalogs
Generalize run_all.py from a RustPython-only runner to a --python/--label
pair, so the same script can catalog a real CPython (with --no-psutil-stub,
since it has a genuine psutil) alongside RustPython. Each label gets its own
results/<label>/ subdirectory.
Add compare.py, which loads two labels' catalogs and writes a per-benchmark
Markdown table with both targets' status/mean and the candidate/baseline
time ratio, plus the median slowdown across benchmarks both targets passed.
Assisted-by: Claude Code:claude-sonnet-5
* ci: compare base, head and CPython with pyperformance on one runner
A ratio between two pyperformance runs measured on different machines can
move further than the change under review did, so a PR's numbers are only
worth reading when base, head and CPython were measured back to back on the
same runner. This adds a job that does exactly that -- two release builds
kept side by side with the stdlib of their own commit, then three runs with
nothing in between -- and posts the table as a PR comment.
`pr_diff.py` renders the three catalogs `run_all.py` writes: per benchmark
the CPython time, both RustPython times, both ratios against CPython, and
the head/base change, with anything under 3% shown as `~` because a shared
runner is not quiet enough to say more.
The comment is handed to a `workflow_run` companion the same way
`codspeed-comment.yaml` does it, since a `pull_request` run from a fork gets
a read-only token however the workflow is configured.
The job is opt-in behind a `run:pyperformance` label: it runs 28 benchmarks
three times over and costs well over an hour, which most PRs do not need.
`run_all.py` now forwards RUSTPYTHONPATH through pyperf, which a binary
copied away from its checkout needs in order to find the stdlib at all; the
two names go in one comma-separated `--inherit-environ`, because repeating
the flag keeps only the last.
Assisted-by: Claude Code:claude-fable-5-1
* ci: comment from the pyperformance run itself when the PR allows it
The `workflow_run` companion only starts firing once it is on the default
branch, so a pull request that introduces it -- this one -- would upload the
table and never show it. A pull request opened from this repo carries a
token that may write comments, so post it from the run that measured it and
leave the companion to the forks that genuinely cannot.
Both paths upsert on the same marker, so a fork PR that reaches the
companion after this step was skipped still lands one comment.
Assisted-by: Claude Code:claude-fable-5-1
* ci: address zizmor findings and fall back to head vs. CPython
- Pin `actions/github-script` to the commit the rest of the repo pins it to;
the hash carried over from an in-flight branch pointed elsewhere than the
`v9.0.0` comment claimed (ref-version-mismatch).
- Read the PR number, the CPython path and version, and the two commit shas
from `env` rather than expanding them into the shell (template-injection).
- Record the `workflow_run` trigger in `.github/zizmor.yml` next to the
existing `pull_request_target` entry, with the same justification: the
workflow reads one artifact and writes a comment, and never checks out or
runs pull request code (dangerous-triggers).
Building or measuring the base commit is now non-fatal, and `pr_diff.py`
renders head against CPython alone when the base column has nothing in it --
a base that will not build should still leave a usable table rather than
failing the job. The time and ratio columns are also named apart, since
`| base | head | base | head |` gave no clue which pair was which.
Assisted-by: Claude Code:claude-fable-5-1
* ci: derive pyperformance comment target from trusted workflow_run metadata
pr_number.txt came from the artifact a `pull_request` run uploads, which a
fork could tamper with to make this privileged `workflow_run` comment on an
arbitrary PR/issue. Resolve the PR from context.payload.workflow_run instead
(falling back to a commit-associated open PR lookup for workflow_dispatch
runs), and escape any HTML comments already present in diff.md so they can't
be mistaken for the marker.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* ci: grant actions:read to the pyperformance comment workflow
download-artifact needs actions:read to fetch another run's artifact by
run-id. Specifying a permissions block sets every unlisted scope to none, so
without this the cross-run download silently failed for fork PRs -- the
scenario this workflow exists for -- continue-on-error masked it, and the
comment step found no diff.md and returned without posting.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: kill the whole process group on a benchmark timeout
subprocess.run's own timeout only terminates the direct pyperformance
process; pyperf re-execs the target interpreter as a child, which can
survive the timeout and keep burning CPU into the next benchmark's
measurement. Run each benchmark in its own session/process group instead,
and on timeout SIGKILL the whole group via os.killpg.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: compute the head-vs-base cell from head_vs_base directly
The cell was derived from base_vs_cpython and head_vs_cpython, both of which
are None when a benchmark has no CPython time -- so it rendered "-" even
though base and head both had valid times and head_vs_base was already
computed. Use that precomputed ratio instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: invalidate the resumed catalog when the target executable changes
catalog.json records results without any fingerprint of target_python, and
resume skips benchmarks by name alone, so a local rebuild (or swapping the
target) under the same --label could silently reuse stale measurements.
Store a sha256 of the executable's contents alongside the catalog and, when
it no longer matches, ignore the existing catalog and re-run everything.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* ci: fall back to github.sha for the head checkout on workflow_dispatch
github.event.pull_request.head.sha is empty on a workflow_dispatch run (no
pull_request payload), so `git checkout --quiet "" --` failed with "fatal:
invalid reference" on this non-optional step, aborting every manual run
before it could measure or render results.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: resolve --out/--cache-dir to absolute paths
Every benchmark subprocess runs with cwd=work_dir (under --cache-dir), so a
relative --out or --cache-dir passed on the command line resolved against
that directory instead of the one run_all.py was invoked from, breaking
catalog output, the pyperformance binary path, and PIP_FIND_LINKS. Both
default to absolute paths already; resolve them up front so a relative
override behaves the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: persist catalog invalidation before the new fingerprint
The fingerprint file was rewritten before the invalidated catalog was ever
written back to disk. An interruption between the two (e.g. a crash during
the first benchmark of the re-run) left a fingerprint matching the new
executable pointing at a catalog.json still full of results measured
against the old one, so the next run would trust it as fresh. Write the
reset (empty) catalog first, then record the fingerprint.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: show benchmarks that fail on both base and head
Rows were dropped whenever neither side had a mean, which also hid a
benchmark that failed or timed out identically on base and head -- e.g. a
C-extension gap unrelated to the PR under review. Only skip a benchmark
never attempted on either commit; keep rows with a fail/timeout status so
they still show up in the table.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: write catalog.json atomically
write_catalog runs after every single benchmark, and Path.write_text
truncates the file before writing the replacement. An interruption
mid-write left catalog.json both missing every earlier result and invalid
JSON, so the next run's resume logic failed outright at json.loads(). Write
to a temporary sibling file and rename it into place instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: fix passed count and median population in the summary table
"Benchmarks passed" counted len(base_ratios)/len(head_ratios), which require
a *CPython* ratio too -- a CPython-only failure hid an otherwise-passing
benchmark from both sides' counts. Count actual "ok" status per side
instead.
The two medians were also computed over independently-filtered
populations: whichever benchmarks had a valid ratio on that side alone. A
benchmark that regressed to failure on only one side dropped out of only
that side's median, which could shift it well beyond what any surviving
benchmark's timing actually changed by. Restrict both medians to
benchmarks with a valid ratio on both sides, and label the population size.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: include RUSTPYTHONPATH's stdlib in the executable fingerprint
The catalog-invalidation fingerprint hashed only the executable's bytes, but
a RustPython binary copied away from its checkout finds its stdlib through
RUSTPYTHONPATH -- pyperf re-execs the target interpreter into a venv and
forwards that variable so it can still find Lib/. Changing that path, or
editing the files under it, without rebuilding the binary left resume
trusting results measured against a now-different stdlib. Fold its contents
into the fingerprint too.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: require an explicit ok/fail status for pass/fail transitions
only_head/only_base flagged a benchmark as newly passing or no longer
passing based only on whether the other side had a mean, so a benchmark
never attempted on one side (e.g. a partial --benchmarks run) was reported
as a regression or fix it never was. Require the other side's status to be
an actual fail/timeout, not just missing.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: don't gate the head/base geometric mean on a CPython ratio
The summary panel -- pass counts and the head/base geometric mean, neither
of which need a CPython comparison -- only rendered when at least one
benchmark also had a valid ratio against CPython on both sides. A build
with a perfectly good head-vs-base comparison but no common CPython result
lost the whole panel, including the one aggregate that didn't depend on
CPython at all.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: normalize RUSTPYTHONPATH and extract main() into named steps
Fix: a relative RUSTPYTHONPATH was fingerprinted relative to this script's
invocation directory but resolved by pyperf's subprocess relative to
work_dir (its cwd), so a relative value could be hashed against the wrong
directory entirely, or fail to resolve at runtime. Resolve it to an
absolute path up front, alongside --out and --cache-dir.
Refactor: main() had accumulated argparse setup, executable resolution, and
the fingerprint/resume block inline, each wrapped in an explanatory comment
-- a sign the function was doing too much rather than that it needed more
narration. Extracted parse_args(), resolve_target_python(), and
load_resumable_catalog() so main() reads as a short sequence of named
steps and each comment sits next to the one function it actually explains.
No behavior change; verified with unit tests against the extracted
functions (fingerprint reacting to RUSTPYTHONPATH, resume picking up a
prior catalog, invalidation on an executable change).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: split pr_diff.py's main() and fix a status-transition gap
Fix: only_head was still gated on have_base, which only asks whether *any*
base benchmark produced a timing -- so a benchmark that flipped from
failing to passing went unreported whenever every other base benchmark
also happened to fail. Status transitions don't need that gate; they
already require an explicit ok/fail/timeout status on both sides.
Refactor: main() had grown into one long function mixing argument parsing,
catalog loading, row computation, and three separate rendering concerns.
Split it into parse_args(), load_base_catalog(), build_rows(),
render_intro(), render_summary_panel(), render_table(), and
find_transitions(), each documenting the one thing it decides. No behavior
change beyond the fix above; re-verified against every scenario exercised
in the last several fixes (dual-fail rows, geo mean without a CPython
ratio, unattempted benchmarks, and the have_base gap) plus the existing
manual smoke tests.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* pyperformance: don't resolve an empty RUSTPYTHONPATH to the cwd
The normalization only checked "RUSTPYTHONPATH" in os.environ, so a set-but-
empty value (RUSTPYTHONPATH="") resolved to the current directory via
Path("").resolve(). executable_fingerprint() would then recursively hash
every file under wherever run_all.py was invoked from -- including its own
results directory while writing to it -- causing spurious catalog
invalidation and a lot of pointless hashing. Check for a nonempty value
instead, matching the truthiness check already used everywhere else this
variable is read.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
* docs(pyperformance): distinguish the host runner from the benchmarked target
A reviewer read "pyperformance cannot be installed as-is on RustPython" and
reasonably asked why RustPython would need to support pyperformance's CLI at
all, since it's normally run as a command under any Python (see
https://github.com/RustPython/RustPython/pull/8691#discussion_r3997957942).
It doesn't: the pyperformance CLI (the host process) always runs under a
real CPython regardless of --python. What actually needs psutil/pyperf
importable is the *benchmark* subprocess -- pyperf re-execs the --python
target and that subprocess itself does `import pyperf`. Spell out that
host/worker split up front instead of leading with "cannot be installed".
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* Classify continuable unclosed strings as incomplete
Mark EOF-open strings for PyCF_ALLOW_INCOMPLETE_INPUT, treat
blank eval input as incomplete, detect unparenthesized lambda
after a comma in f-strings, and advance parameter scans past
default values.
Assisted-by: Grok:4.6
* Diagnose incompatible prefixes and nested f-strings
Report incompatible string prefixes, malformed \\N escapes, and
f/t-string nesting beyond 150. Omit the extra newline on
unterminated triple-quoted f-string SyntaxError.text.
Assisted-by: Grok:4.6
* Fix empty defaults and longer incompatible prefixes
Report an empty parameter default before later parameters, collect
the full prefix before a quote, and prefer the u/b pair.
Assisted-by: Grok:4.6
* sqlite3: fix iterdump import and filter support
Fix Connection.iterdump() to import sqlite3.dump with a from-list and forward its keyword-only filter argument, matching CPython 3.14. Remove stale expected-failure markers from all passing iterdump tests.
Assisted-by: GitHub Copilot:GPT-5.6 Luna (high)
* sqlite3: fix clippy core iterator lint
Use core::iter instead of std::iter in the iterdump filter kwargs path, as required by RustPython clippy. Add the sqlite3 expected-failure workflow and CI clippy feedback reports.
Assisted-by: GitHub Copilot:GPT-5.6 Luna (high)
* host_env: share file identity, dll dirs, link and startfile
Add GetFileInformationByHandle, AddDllDirectory/RemoveDllDirectory,
CreateHardLinkW, ShellExecuteW, and a wide ExpandEnvironmentStringsW
reader that keeps unpaired surrogates.
Assisted-by: Claude
* vm: use host_env for startfile, dll dirs and link
Wire nt.startfile, nt._add_dll_directory/_remove_dll_directory
and Windows os.link through the host_env wrappers.
ExpandEnvironmentStrings keeps unpaired surrogates via the
wide reader.
Assisted-by: Claude:grok-4.6
* host_env: publish Windows =X: drive cwd for spawn
Extract publish/ensure helpers from set_current_dir and call
ensure before _wspawnv/_wexecv so CRT env walks have a first
=X: entry.
Assisted-by: Claude:grok-4.6
Add PyStr::as_utf8() for a non-erroring UTF-8 view. Thread
PyUtf8Str through import resolution, module attribute errors,
and IMPORT_FROM instead of converting names to owned String.
Assisted-by: Grok:4.6
Raise RuntimeError on send/throw of a closed coroutine, track
cr_origin, emit never-awaited warnings through the warnings helper,
and add cr_suspended. Stop treating coroutines as iterable. Warn on
unawaited asyncgen asend/athrow/aclose, match async for TypeError
messages, and attach coroutine method and name getset docs.
Assisted-by: Grok:grok-4.6
Match CPython 3.14 by distinguishing row_factory assignment from deletion and raising AttributeError with the compatible message. Unmark the passing row_factory deletion test.
Assisted-by: GitHub Copilot:GPT-5.6 Luna (high)
* asyncio: honor pending-task, unawaited, and get_referrers
Report Task destructor as 'Task was destroyed but it is pending!'.
Warn when a never-started coroutine is collected. Preserve signal()
errno. Attribute generator-owned frame locals to the owner in
gc.get_referrers. Remove the expectedFailure markers that now pass.
Assisted-by: Grok:grok-4.6
* tests: drop expectedFailure after unawaited warning
The never-started coroutine RuntimeWarning unblocks
test_bpo_45813_1 and the AsyncMock assertNeverAwaited cases.
Assisted-by: Grok:grok-4.6
* common: implement remaining builtin text codecs
Move utf-16/32/7, unicode-escape, raw-unicode-escape and the
bytes escape transform into rustpython-common and call them from
_codecs instead of _pycodecs.
Assisted-by: Claude:grok-4.6
* host_env: share locale grouping, uuid and pipe state
Add localeconv_numeric so grouping keeps a CHAR_MAX terminator,
UuidCreateSequential for _uuid, and GetNamedPipeHandleStateW.
Assisted-by: Claude:grok-4.6
* Fix utf-7 clippy and the utf-16-be snippet length
Assisted-by: Claude:grok-4.6
* codecs: treat escape decode as final and accept str
unicode_escape_decode and raw_unicode_escape_decode default final to
true and accept a str as UTF-8. Fix clippy on wide_order, escape
encode, and encode closures. Remove expectedFailure markers that now
pass.
Assisted-by: Grok:grok-4.6
* Warn on invalid octal escapes and parse-fail strings
Treat three-digit octal values above 0o377 as invalid escapes and
scan quoted literals even when parse fails, so SyntaxWarning is
emitted before a later SyntaxError. Keep warning and SyntaxError
text on InvalidEscape.
Enable the remaining test_string_literals invalid-escape cases.
Assisted-by: Grok:4.6
* Remove expectedFailure from passing test_codeop cases
test_invalid_warning and test_raw_raises_error now emit
SyntaxWarning on parse-fail invalid escapes.
Assisted-by: Grok:4.6
* Scan unparsed strings with token-boundary prefixes
Require a complete prefix at an identifier boundary, and walk
f-string interpolations separately after a parse failure.
Assisted-by: Grok:4.6
* Fix -m argv[0] and file SyntaxError display
Set sys.argv[0] to -m for module execution. Convert an escalated
invalid-escape SyntaxWarning into a SyntaxError that spans just
the `\X` pair. Report null bytes in source files with filename,
lineno, and the truncated line.
Enable the four corresponding test_cmd_line_script cases.
Assisted-by: Grok:4.6
* Pass SyntaxError text when escalating escape warnings
Keep the warning and SyntaxError messages as separate strings at
the invalid-escape site. CompileWarningError carries an optional
replacement instead of rewriting the warning text later.
Assisted-by: Grok:4.6
* Remove expectedFailure from bytes invalid-escape test
The invalid-escape SyntaxError path now satisfies
test_eval_bytes_invalid_escape.
Assisted-by: Grok:4.6
* Report `bytes` out-of-range elements as CPython does
`collect_bytes` is shared by the `bytes` and `bytearray` entry points and
hardcoded one element error, so `bytes([256])` said "byte must be in
range(0, 256)" where CPython says "bytes". Every `bytearray` path does say
"byte", so only the one caller was wrong.
The element error is now a parameter, alongside the type error this
function already varies per caller. Verified against CPython 3.14 for all
seven paths.
Assisted-by: Claude Code:claude-opus-5
* Keep the bytearray wording in PyByteArray_FromObject
It called `bytes_from_object`, so the previous commit made it report
"bytes must be in range(0, 256)" where CPython's `PyByteArray_FromObject`
says "byte". It is the C-level bytearray constructor, so it now uses
`bytearray_from_object`, which carries that wording and the constructor's
unsized iteration.
Assisted-by: Claude Code:claude-opus-5
Expose HOSTFLAG_NEVER_CHECK_SUBJECT and _host_flags so ssl.py can
disable Common Name fallback. HAS_TLS_UNIQUE matches the TLS 1.2
channel binding we already implement.
Assisted-by: Grok:grok-4.6
* Leave Callee out of a generated __text_signature__
The interpreter supplies `callee` the way it supplies `vm`, but only `vm`
was filtered, so the argument surfaced as a Python parameter and left a
string inspect cannot parse:
>>> object.__getstate__.__text_signature__
'(*args, **kwargs, callee)'
>>> inspect.signature(object.__getstate__)
ValueError: builtin has invalid signature
Filter it in `func_sig`, and in `infer_native_call_flags`, which counted
it as a fixed positional argument. `object.__getstate__` is the only
#[pymethod] taking one today, inherited by 95 types.
Assisted-by: Claude Code:claude-opus-5
* Rename maketrans's first parameter to frm
`from` is a Python keyword, so the generated signature could not be
parsed:
>>> bytes.maketrans.__text_signature__
'(from, to, /)'
>>> inspect.signature(bytes.maketrans)
ValueError: builtin has invalid signature
CPython's Argument Clinic spells it `frm` for the same reason. Both
parameters are positional-only, so the name is documentation only.
`bytes.maketrans` and `bytearray.maketrans` now report what CPython
reports, `(frm, to, /)`.
Assisted-by: Claude Code:claude-opus-5
* Store ContextVar.name as the original str object
Keep the constructor argument instead of converting it to a Rust String
so lone surrogates and str subclasses are preserved. Build __repr__
from the name and default reprs.
Assisted-by: Grok:4.6
* Compare Context objects by their variable maps
Implement Context ==/!= from the mapping contents and mark Context
unhashable. Snapshot the map before value equality so re-entrant
ContextVar.set during __eq__ cannot deadlock.
Enable test_context.ContextTest.test_context_run_4.
Assisted-by: Grok:4.6
Replace openssl-probe and local std::fs checks with host_env
native_certs and fs. Vendored OpenSSL loads system CA paths
from host_env; OpenSSL's own defaults stay for a system lib.
Assisted-by: Grok:grok-4.6
* unicodedata: resolve name aliases and named sequences
Vendor Unicode 17 NameAliases.txt and NamedSequences.txt into
rustpython-unicode so unicodedata.lookup matches CPython: formal
aliases and named sequences on the modern view, none on ucd_3_2_0.
Tangut derived-name lookup is case-insensitive. \N{} still rejects
named sequences because they are not a single character.
Assisted-by: Claude
* test_ucn: drop expectedFailure on test_aliases
The name-alias tables make the test pass; leaving the marker
fails CI as an unexpected success.
Assisted-by: Claude
* unicode: reject whitespace in Tangut derived names
parse_hex_code does not skip spaces around the hex digits.
Assisted-by: Claude
TlsConnection, RecordCursor, rustls error mapping, hostname/ALPN/version
helpers, and the capturing client session store now live in host_env.
stdlib _ssl keeps socket/MemoryBIO I/O and Python objects.
Remove unused stdlib sha2 and leftover workspace TLS crates.
Assisted-by: Grok:grok-4.6
* fix(vm): report which format string mistake was made
`ToPyException for FormatParseError` mapped two variants and sent the rest to
"Unexpected error parsing format string", so most format-string mistakes gave
no hint about the mistake. Against CPython 3.14.0:
| expression | before | CPython |
| --- | --- | --- |
| `"a}b".format()` | Unexpected error… | Single `}` encountered in format string |
| `"{0.}".format(1)` | Unexpected error… | Empty attribute in format string |
| `"{0[]}".format([1])` | Unexpected error… | Empty attribute in format string |
| `"{0[1}".format([1,2])` | Unexpected error… | expected `}` before end of string |
| `"{0[0]x}".format([1])` | Unexpected error… | Only `.` or `[` may follow `]` in format field specifier |
| `"{:{{}}".format(1)` | Unexpected error… | unmatched `{` in format spec |
The match is now exhaustive, so a new variant cannot silently inherit the
generic message.
Two cases are deliberately left generic, with the reason in a comment beside
each. `UnknownConversion` is raised both for a multi-character conversion
(`{0!xy}`, where CPython says "expected ':' after conversion specifier") and
for an empty one (`{0!}`, "unmatched '{' in format spec"), so one message
cannot serve both without the parser saying which it hit. And a trailing lone
`{` reaches `UnmatchedBracket` rather than
`UnescapedStartBracketInLiteral`, so `"{".format()` still differs from CPython;
that needs a parser change, not a message.
Expectations in the new snippet are CPython 3.14.0's output and pass under both
interpreters. Reverting only format.rs fails the snippet's first assertion.
Assisted-by: Claude Code:claude-opus-5
* fix(common): separate a stray `{` from an unclosed field
`parse_literal` already reports `UnescapedStartBracketInLiteral` for a brace
that was not doubled, but `from_str` discards it with `or_else` and retries as a
field, so `"{".format()` surfaced `UnmatchedBracket` and read as
"expected '}' before end of string". CPython separates the two by whether
anything follows the brace:
"{" "a{" Single '{' encountered in format string
"{s" "a{b" expected '}' before end of string
"{0" expected '}' before end of string
`parse_spec` now returns the literal error when the text is the brace alone,
which is also what makes `UnescapedStartBracketInLiteral` reachable — the
previous commit could map it but not trigger it.
`format_parse_lone_start_bracket` pins both directions at the parser level, and
the snippet covers the four messages under CPython 3.14.0 as well. The existing
`format_parse_fail` assertion for `"{s"` is unchanged.
Assisted-by: Claude Code:claude-opus-5
* ssl: move remaining rustls engine into host_env
Cert loading, rustls verifiers, ClientConfig/ServerConfig construction,
key logging, acceptor helpers, and X509 error mapping now live next to
the trust store. stdlib _ssl keeps the Python object and socket adapters.
Assisted-by: Claude
* Remove unused workspace SSL dependencies
Drop oid-registry, rustls-platform-verifier, and x509-cert from
workspace.dependencies.
Assisted-by: Grok 4.6
* ssl: fire msg callbacks and compute tls-unique
Observe TLS records to invoke _msg_callback, and derive TLS 1.2
tls-unique from the KeyLog master secret plus rustls PRF.
Restore CHANNEL_BINDING_TYPES and drop the remaining test_ssl
RUSTPYTHON skips.
Assisted-by: Claude
* lzma: build the xz-core engine on wasm32
Expose `_lzma` on wasm32 and Android by compiling the xz-core
engine on those targets instead of gating it out.
Assisted-by: Claude
* ssl: move the rustls engine into rustpython-common
Extract the VM-independent rustls helpers (MemoryBio, certificate
decode, cipher strings, OID table, chain builder, providers, and
TLS record observation) so stdlib _ssl wraps a shared engine.
Assisted-by: Claude
* ssl: keep the rustls engine in host_env
TLS helpers share the host trust store and default verify paths, so
they belong next to native_certs rather than in rustpython-common.
Assisted-by: Claude
* stdlib: drop unused jiff after moving cert decode
Assisted-by: Claude
Hold the rustls connection mutex only around rustls operations
in handshake, read, write, and shutdown. Socket and MemoryBIO
waits run without that lock so a blocking recv cannot deadlock
a concurrent send.
Remove the hang skip on test_thread_recv_while_main_thread_sends.
Assisted-by: Claude
* Align contextvars, CLI startup, and stat validation with CPython
Validate Context and ContextVar arguments and mapping keys, hash names through the Python protocol, and preserve string contents without invoking __str__. Set the main module loader for command and stdin execution, report missing scripts with exit status 2, and reject file descriptors combined with follow_symlinks=False.
Enable the nine corresponding stdlib regression tests.
Assisted-by: Codex:gpt-6
* Move set_main_builtin_importer off the compiler feature
Define the method in vm_new.rs so builds without rustpython-compiler,
such as example_projects/barebone, can compile. Also set BuiltinImporter
on an existing __main__ when its loader is missing or None.
Assisted-by: Grok:4.6
Keep BIO writes from filling asyncio's socket transport past its
high-water mark when SO_SNDBUF is small. Drop the Unix skip on
test_sendfile_ssl_pre_and_post_data.
Assisted-by: Claude
Pin the RustPython Ruff fork to the patch commit based on Ruff 0.16.5 and adapt compiler and AST integration to the updated APIs.
Assisted-by: Codex:GPT-5
* ssl: accept ClientHello before selecting the SNI context
Replace the provisional server connection and replay flags with explicit handshake states. Retain fatal alerts across nonblocking retries and preserve fragmented input on timeout. Enable the three SNI alert regressions.
Assisted-by: Codex:GPT-5
* ssl: share socket and MemoryBIO transport progress
Queue drained TLS records before fallible output and use one handshake record loop for both transports.
Assisted-by: Codex:GPT-5
* ssl: unify shutdown and fatal alert lifecycle
Track close-notify progress in TlsState, preserve pending alerts across retries, and share record-boundary shutdown for sockets and MemoryBIO. Retain rustls errors until Python exception conversion.
Assisted-by: Codex:GPT-5
* ssl: emit the full peer certificate dict
Use the same certificate dict helper for getpeercert() and
Certificate.get_info() so OCSP, caIssuers, and CRL URLs are present.
Clear CHANNEL_BINDING_TYPES on the rustls backend, and add a MemoryBIO
leftover-plaintext snippet.
Assisted-by: Claude
* ssl: add key logging with a shared host append sink
Port the context-owned keylog sink design from Pyre, retaining CPython 3.14 path and context-switch semantics. Keep host file lifecycle in host_env and TLS formatting in stdlib.
Assisted-by: Codex:GPT-5
* ssl: use core and alloc imports for key logging
Assisted-by: Codex:GPT-5
Accept __index__ values when converting resource limits and only report PyREPL fallback reasons for terminal-backed interactive sessions.
Assisted-by: Codex:gpt-5
Port the connection-owned chain builder from Pyre. Preserve verification inputs with TLS configurations and sessions, report the WebPKI-selected path, and publish only its selected capath anchor. Match CPython chain reporting for CERT_NONE and resumed sessions.
Assisted-by: Codex:GPT-6
`PyStr::__add__` delegated to the right operand's `__radd__` whenever it had
one, and returned whatever came back. For every numeric type that is a
`NotImplemented`, which then reached the generic binary-op handler:
>>> "a" + 1
TypeError: unsupported operand type(s) for +: 'str' and 'int'
CPython falls back to `str`'s `sq_concat` once the reflected call declines, so
it names the concatenation instead:
TypeError: can only concatenate str (not "int") to str
The specific message was already here, but only reachable for operands with no
`__radd__` at all, so `list`, `object`, `bytes` and `None` were correct while
`int`, `float`, `bool` and any class with a declining `__radd__` were not.
A `__radd__` that returns a value still wins, unchanged.
Verified against CPython 3.14.0: the new snippet asserts the message for
`int`, `float`, `bool`, `list`, `None`, `bytes` and a declining `__radd__`,
and passes under both interpreters. Reverting only the `str.rs` change fails
its first assertion.
Assisted-by: Claude Code:claude-opus-5
* Fix /dev/fd, rlimit, spawn scheduler, and context cache
Honor PYTHONEXECUTABLE when computing sys.executable.
Rewind the file offset after a pyc magic probe.
Stop masking rlimit values with RLIM_INFINITY.
Print the pyrepl-unavailable warning before the rustyline shell.
Parse posix_spawn scheduler and apply it where the host supports it.
Update ContextVar cache fields under one lock.
Remove expectedFailure and skip markers for tests that now pass.
Assisted-by: Grok:4.6
* address review: check rlim_t overflow on convert
Replace the u64-to-rlim_t as-cast in py2rlim_limit with
a checked try_from, matching py2rlim.
Assisted-by: Grok:4.6
* Add no_memory_error for allocation failures
Assisted-by: Claude Code:claude-fable-5-1
* Use no_memory_error at allocation failure sites
Assisted-by: Claude Code:claude-fable-5-1
* Raise MemoryError instead of aborting on sequence repeat allocation failure
Vec::with_capacity and Vec::reserve in SequenceExt::mul and
SequenceMutExt::imul call handle_alloc_error on failure, which aborts
the process under panic = "abort". `[1, 2, 3] * 10**17` passes the
MAX_MEMORY_SIZE guard (2.4e18 bytes < isize::MAX) and aborted at the
allocation instead of raising MemoryError.
Use try_reserve_exact and map failures to vm.no_memory_error(). This
also removes the n != 2 special case in imul: with the reserve done
unconditionally, the copy loop runs zero times for n == 2 and the
final append uses the reserved capacity.
Assisted-by: Claude Code:claude-fable-5-1
* Recycle MemoryError instances through a dedicated payload freelist
no_memory_error allocated the exception object on every raise, so
under real memory exhaustion the raise itself could abort. Keep dead
MemoryError husks in a process-wide reserve and revive them on the
next raise without touching the allocator.
The freelist is scoped to MemoryError at the type level. PyMemoryError
already exists as a transparent wrapper payload, but instances never
used it: the default exception slot_new delegates to the base class,
so everything was constructed as PyBaseException. Route
no_memory_error through a PyMemoryError-typed construction instead;
the freelist hooks live on PyMemoryError's own PyPayload impl, the
dealloc glue is monomorphized per payload type, and the existing
exact-type push gate admits exactly MemoryError husks.
The #[pyexception] macro always generates the PyPayload impl, which
left no way to attach freelist configuration; a payload = "manual"
attribute now skips that generation so a type can write its own impl,
mirroring the generated PAYLOAD_TYPE_ID chain and class-based
downcast validation that keep the payload flavors interchangeable.
Exceptions are the first HAS_DICT freelist type, so their husks carry
an ObjExt prefix that PyInner::dealloc would normally drop; clear its
instance dict and member slots before pushing so no stale attributes
survive into a revived instance.
The reserve is a process-wide Mutex rather than a thread_local so a
single prewarm at interpreter init covers every thread; MemoryError
is a cold path, so the lock is uncontended. Python-level MemoryError()
still constructs a PyBaseException payload through the delegated
slot_new and simply does not participate, matching CPython, where
only the PyErr_NoMemory path uses the preallocated reserve.
Assisted-by: Claude Code:claude-fable-5-1
* Clear MemoryError husks before they enter the freelist
Assisted-by: Claude Code:claude-fable-5-1
* Use no_memory_error for the bz2 allocation failure
The shared bz2 engine maps BZ_MEM_ERROR to Bz2Error::Mem; report it
through no_memory_error like the other allocation-failure sites, matching
PyErr_NoMemory in CPython's _bz2module.
Assisted-by: Claude Code:claude-fable-5-1
* Change MemoryError husks Vec to a fixed-size array
Assisted-by: Claude Code:claude-fable-5-1
* Increase MemoryError freelist size from 4 to 16
* Address review: keep repeat and husk clearing allocation-safe
Assisted-by: Claude Code:claude-fable-5-1