* Align compiler futures and annotations with CPython
Handle Barry parsing consistently across AST, type-comment, REPL, and WASM paths. Preserve deferred annotation source and scope metadata, and make _symtable conversion cached and linear-time.
Assisted-by: Codex:gpt-5.4
* Fix f-string debug ranges and update Barry/annotate test expectations
Compute the debug f-string source range from the raw leading and
trailing text instead of the comment-stripped text, so a comment inside
a multi-line replacement field no longer shifts the emitted LOAD_CONST
location.
Restrict the obsolete-operator location shift to `<>` by also requiring
a `>` at the reported offset; without it any `ExpectedExpression` that
followed a `<` (`2 <;`) was reported one column to the left.
Add `CodeFlags::FUTURE_MASK` and use it in builtins, the shell, and the
WASM VM instead of repeating the eight-flag union, and collapse the
duplicated Barry diagnostic sequences into `BarrySource::diagnostic`.
Update the `__annotate__` disassembly snapshot to LOAD_FAST_BORROW and
replace the RustPython-only `barry_as_FLUFL` co_flags assertion in
extra_tests with the CPython-matching one.
Assisted-by: Claude Code:claude-opus-5
* Restore the annotated function in __annotate__ qualnames
Signature annotation scopes are compiled in the scope enclosing the
annotated function, so the function name has to be folded back into the
qualname: `f.__annotate__`, `C.m.__annotate__`,
`outer.<locals>.inner.__annotate__`. test_type_annotations
test_annotate_qualname covers this.
test_pyrepl test_future_barry_as_flufl now passes, so drop its
expectedFailure marker.
Assisted-by: Claude Code:claude-opus-5
* Pass safepoints in the attached-thread interpreter tests
`main_and_subinterpreter_run_sections_overlap` parked its workers on a
condvar while attached, and `busy_main_interpreter_does_not_block_subinterpreter`
looped over protocol calls that never reach a safepoint. An attached
thread that never reaches a safepoint cannot be suspended, so a
concurrent process-wide stop-the-world (from the gc test running in
parallel) never completes and the already-stopped sibling interpreter
stays stopped; the second worker then waits in `wait_while_suspended`
until the 30s deadline.
Both loops now call `vm.check_signals()` each iteration, and the condvar
wait uses `wait_timeout` so the lock is released between safepoints.
Reproduced on Linux (4 CPUs): the two tests with `--test-threads=2`
failed 2/40 before and 0/40 after; the full `rustpython-vm` lib binary
failed 1/30 before and 0/30 after.
Assisted-by: Claude Code:claude-opus-5
* Report the obsolete `<>` operator from one place
`<>` was located twice: `BarrySource` recorded the token ranges it
rewrote to `!=`, and `cpython_parse_diagnostic_override` separately
peeked at the bytes around an `ExpectedExpression` location. Both
produced "invalid syntax" spanning the whole operator.
`prepare_barry_as_flufl_source` now records the operator ranges in the
non-Barry case too -- by plain text search, since nothing is rewritten
there -- so `BarrySource::invalid_legacy_operator` covers both, and the
byte-peeking helper is gone. It also defers to an unclosed bracket
earlier in the source, which the diagnostic chain it used to sit in did
for it.
A `<>` that starts a statement now spans both characters: the parser
stops at the `<` rather than one character in, which the byte peek did
not handle.
Assisted-by: Claude Code:claude-opus-5
* Drop a py object's payload before its class
`PyInner` declares `typ` before `payload`, so `drop_in_place` dropped the
class first and `PyAtomicRef::drop` left it null. A `PyWeak` payload is
still linked into the weakref list of the object it points at until its
own `Drop` unlinks it under the stripe lock, which happens after that.
`WeakRefList::add` walks the same list looking for a proxy to reuse and
reads `node.class()` off every node it passes, so it could dereference
the null class of a node on its way out.
`PyInner::dealloc` now runs the two destructors in the other order at all
three of its exit paths, with a compile-time check that no other field
has one.
Reproduced by the new test in about 0.1s, as the panic CI hit in the
c-api `weakrefobject::tests::new_proxy` run:
panicked at crates/vm/src/object/ext.rs:312:
unsafe precondition(s) violated: hint::unreachable_unchecked must
never be reached
Assisted-by: Claude Code:claude-opus-5
* Collapse bare ExpectedExpression to 'invalid syntax'; fix '<>' diagnostic offset
`ParseErrorType::ExpectedExpression` currently surfaces as the raw ruff
parser message (e.g. "Expected an expression") to callers that only
depend on `rustpython-compiler` (no `rustpython-vm`). `rustpython-vm`'s
`vm_new.rs` already collapses this to CPython's generic "invalid
syntax" for its own callers; mirror that same collapse inside
`cpython_parse_diagnostic_override` so non-vm consumers get the same
CPython-compatible message.
A bare `<>` outside Barry-as-BDFL mode (`2 <> 3`) lexes as `Less` then
an unexpected `Greater`, so the resulting `ExpectedExpression` location
points at the `>` -- one character past where CPython's tokenizer
(which treats `<>` as a single obsolete token) reports the error.
Detect the `<` immediately preceding the location and shift the
reported range back over it.
Assisted-by: Claude Code:claude-sonnet-5
* Require an adjacent '>' before treating '<' as the obsolete <> operator
CodeRabbit review on #8540: the previous check only looked at the byte
before the ExpectedExpression location for '<', without confirming an
adjacent '>' really follows it. For inputs like a trailing '<' at EOF
this could misclassify an unrelated ExpectedExpression as the bare '<>'
case and report a bogus range. Require both bytes are present before
constructing the diagnostic.
Also remove the now-stale `@unittest.expectedFailure # TODO: RUSTPYTHON`
markers on test_guido_as_bdfl and test_barry_as_bdfl_relative_import,
which pass with this fix (test_barry_as_bdfl and
test_barry_as_bdfl_look_ma_with_no_compiler_flags still need real
Barry-as-BDFL tokenizer support and stay marked).
Assisted-by: Claude Code:claude-sonnet-5