Commit Graph
563 Commits
Author SHA1 Message Date
youknowdot c516ca95df Preserve requested encoding names in codec lookup errors (#9036)
Extract the Python 3.14-compatible lookup diagnostic fix from #8954 while retaining the existing registry normalization. Cover original error spelling and normalized search-hook names in the existing codec snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:47:59 +09:00
youknowdot 386cd86aef Preserve FunctionType qualified names when overriding names (#9032)
Extract the independent Python 3.14-compatible constructor fix from #8954. An explicit name replaces __name__ while __qualname__ remains the code qualified name. Add a focused regression to the existing types snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:41:23 +09:00
youknowdot 1c7c801a3b Accept dict subclasses returned by module annotation functions (#9033)
Extract the Python 3.14-compatible annotation result check from #8954 without its Python 3.15 diagnostics. Preserve the returned dict subclass and cached identity, and cover the behavior in the existing module snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:36:57 +09:00
youknowdot 7079e70b79 Honor warning instance categories before validating category arguments (#9034)
Extract the Python 3.14-compatible ordering fix from #8954. An existing Warning instance determines its own category, regardless of the category argument. Keep canonical invalid-category coverage and add only the missing instance case to the existing warnings snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:36:20 +09:00
1ndahous3 dcdd5d45c3 Avoid copying strings when replace finds no match (#9029)
Assisted-by: Codex:gpt-6
2026-10-10 19:35:48 +09:00
youknowdot 7c9a0e32b3 Traverse references held by operator callables (#9044)
Extract attrgetter, itemgetter and methodcaller GC traversal from #8954. Add four bounded reference-cycle cases to the existing operator snippet, including a non-dotted str subclass retained by attrgetter.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:34:41 +09:00
youknowdot 9c8b745bfe Reject conflicting member layouts in multiple inheritance (#9041)
Extract the Python 3.14-compatible solid-base check from #8954. Prefix member cells contribute to instance layout even though they do not change basicsize. Include member_count in shape comparison while preserving all native layout safeguards, and cover conflicting and compatible bases in the existing type snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:34:12 +09:00
youknowdot 5dba000d8b Preserve raw mappingproxy rich-comparison results (#9039)
Extract the Python 3.14 comparison contract from #8954 without its 3.15 ordering restrictions or defensive copies. Return the wrapped mapping comparison result without truth conversion. Cover all six direct and reflected operations in the existing mappingproxy snippet.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:33:32 +09:00
youknowdot e3374c8a24 Support pickling slot wrapper descriptors (#9037)
Extract wrapper descriptor reduction from #8954 for Python 3.14. Reduce to getattr on the defining class and cover direct reduction plus one roundtrip in the existing pickle snippet. Preserve canonical expected failures for unrelated staticmethod descriptor behavior.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:32:52 +09:00
youknowdot b725188965 Represent OrderedDict views with their contents (#9038)
Extract the Python 3.14-compatible view representation from #8954. Snapshot view elements before invoking their repr methods, preserve recursion handling, and cover each view in the existing collections snippet. Leave migration-specific mapping changes out.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 19:32:22 +09:00
1ndahous3 11a8de1a87 Release array and list locks around fromlist conversions (#9030)
Assisted-by: Codex:gpt-6
2026-10-10 09:24:37 +09:00
youknowdotandJeong YunWon f5b6526c49 Support compile(module=...) across AST warning paths (#8947)
* Support compile module context across AST warning paths

Add Python 3.15 compile(module=...) warning filtering. Move format-spec diagnostics to a fallible, literal-aware AST boundary; preserve nested literal warnings while excluding raw text and comments, map function-type fragments to source locations, and suppress duplicate type-comment emissions with per-call tracking.

Keep unrelated legacy warning-detection and exact diagnostic metadata gaps documented by differential probes. Add focused flag, source-location, exception, reentrancy, filtering and literal-boundary regression coverage.

Assisted-by: Codex:model-version-unavailable

* Adapt compile module context to the current parser APIs

Convert the single-mode multiple statements error into the generic
parse error type, and iterate f-string parts through FStringPartRef.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2026-10-10 00:50:55 +09:00
이광효andJeong YunWon a8e4bde885 Reject unsupported native keywords before argument binding (#8957)
* Reject unsupported native keywords before argument binding

Add explicit keyword dispatch metadata independently of inferred Rust
calling flags. Reject nonempty keywords before binding and conversion,
while preserving descriptor self checks and keyword-capable calls.

Annotate 31 builtins and list.append/list.clear, derive C-API policies
from ml_flags, and group dynamic registration metadata in MethodDefSpec.
Add regression coverage and remove the id doctest expected-failure marker.

Validation: workspace and C-API tests/clippy, VM without doc, keyword
regressions, and test_call/test_extcall/test_builtin/test_list passed.
The full snippet suite had 475 passes and 7 failures: six CPython-side
expectation mismatches and one missing optional SQLite module.

Assisted-by: Codex:GPT-6

* Infer native keyword dispatch from argument metadata

Replace no_keywords annotations with registration-time inference from
FromArgs::PARAMS, including nested parameter metadata. Forward arguments
with keyword-capable parameters to the binder, preserving min/max body
validation and descriptor self checks.

Add regressions for raw arguments, keyword argument structs, and list.sort.

Tested: C-API tests, workspace and C-API Clippy, VM without doc, both keyword
regression snippets, and test_call/test_extcall/test_builtin/test_list.
Workspace tests reported eight _opcode snapshot failures. The full snippet
suite reported 477 passes and seven failures: six CPython-side failures
and one RustPython failure due to the missing optional SQLite module.

Assisted-by: Codex:GPT-6

* Simplify native function registration metadata

Reuse SimpleItemMeta for pyfunction attributes and remove FunctionItemMeta.
Remove MethodDefSpec and restore the original new_method_def arguments
with an additional keyword_dispatch parameter, updating its callers.

Consolidate keyword dispatch regressions in syntax_function_args.py,
preserving their assertions and placing them before builtin shadowing.

Validation: workspace and C-API tests/clippy, VM without doc, the combined
snippet, and test_extcall/test_builtin/test_list/test_call passed.
The full snippet suite reported 477 passes and seven existing failures:
six CPython-side failures and one missing optional SQLite module.

Assisted-by: Codex:GPT-6

* Reject native keywords by calling convention flags

Remove `KeywordDispatch`, the `keyword_dispatch` field of `PyMethodDef`,
`PyMethodDef::with_keyword_dispatch`, `function::keyword_dispatch` and
the derive macros' `keyword_dispatch_tokens`. Native functions and method
descriptors reject nonempty keywords when `flags` lacks `KEYWORDS`, and
report the unqualified name when `flags` contains `VARARGS`.

`Context::new_method_def` takes `(name, f, flags, doc)` again. Add a
snippet for `int.__new__` called with a keyword argument.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2026-10-10 00:49:44 +09:00
youknowdot 42778444a8 Preserve defaultdict subclasses in union results (#9026)
Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-10 00:47:49 +09:00
youknowdot 87aedfb7c5 Preserve Windows time conversion error classes (#9022)
* Cover Windows time conversion error classes

Require OSError with EINVAL for representable timestamps rejected by the Windows C runtime, while preserving OverflowError for float(2**63). This initial regression-only commit intentionally exposes the current Windows error mapping before the implementation follows.

AI assistance covered source comparison, regression design, and automated Linux baseline/reference controls. Native Windows results are pending. No human validation is claimed.

Assisted-by: Codex:model-version-unavailable

* Record native Windows time conversion outcomes

The first hosted regression run failed on CPython 3.14.7 as well as RustPython because a presumed-invalid CRT timestamp succeeded. Add bounded diagnostics before the unchanged assertions to capture full version/build metadata and every conversion result, including negative half-day controls. No implementation or canonical test changes are included.

The existing time snippet still passes the repository pytest runner on Linux CPython 3.14.7 and the current RustPython baseline. Native diagnostic results remain pending.

Assisted-by: Codex:model-version-unavailable

* Use the observed UCRT rejection boundary in time regression

Hosted Windows diagnostics show that CPython 3.14.7 and RustPython both accept gmtime(-1) and gmtime(-43200), while -86400 is rejected by all three converters. Correct only the newly added shared negative test value. CPython raises OSError(errno 22) for every selected rejected value, while the RustPython baseline raises OverflowError. Canonical tests and the recorded diagnostics remain unchanged.

The existing snippet passes both Linux reference and baseline controls. Assisted source investigation and automated verification used no manual validation.

Assisted-by: Codex:model-version-unavailable

* Preserve Windows CRT time conversion errors

Return CRT errno failures from the Windows calendar helpers and translate them to Python OSError. Adapt the datetime caller while retaining its Unix behavior. Use an exclusive signed float upper bound so float(2**63) still raises OverflowError before reaching the CRT.

Keep Windows negative-time FILETIME fallback and time64 ABI changes outside this Python 3.14 extraction. Existing datetime local-error coverage is retained and a UTC error control is added for the observed rejected timestamp -86400.

Hosted native diagnostics prove CPython 3.14.7 raises OSError(errno 22) where the baseline raises OverflowError. Windows-GNU host_env check and warnings-denied Clippy pass. Selected canonical datetime and complete time/datetime snippet Linux controls pass, with six existing baseline canonical skips. Fixed native Windows verification remains pending CI.

AI assistance covered source comparison, implementation, regression design, and automated verification. No manual validation is claimed.

Assisted-by: Codex:model-version-unavailable
2026-10-10 00:41:40 +09:00
youknowdot d4b43b860d Translate WASI signal dispositions through libc sentinels (#9024)
Keep Python disposition values distinct from WASI function-table pointers. Recognize wasi-libc SIG_ERR before updating Python handlers and preserve ignored/default/custom dispositions. Add synchronous signal and rejected-registration regressions to the existing snippet.

AI assistance covered source investigation, implementation, and automated reference/baseline tests. Isolated patched runtime validation is pending. No human validation is claimed.

Assisted-by: Codex:model-version-unavailable
2026-10-09 23:59:43 +09:00
youknowdot bf984b465e Fix itertools.compress iterator consumption order (#9025)
Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 23:58:08 +09:00
youknowdot 59b36dd426 _zoneinfo: reject empty quoted POSIX TZ abbreviations (#9017)
* Reject empty quoted POSIX timezone abbreviations

Split the Python 3.14-compatible parser guard from #8954. Cover empty standard and daylight-saving abbreviations and preserve valid quoted names.

Assisted-by: OpenAI Codex:model identifier unavailable

* Keep zoneinfo regression in module snippet

Rename the snippet as requested during review without changing test contents.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 23:29:16 +09:00
youknowdot 8986de27cc Preserve CSV dialect conversion errors and ordering (#9020)
Collect raw dialect fields and keyword overrides before converting them in CPython 3.14 order. Preserve truth-conversion exceptions, read classes without instantiating them, and retain defaulting for failed attribute lookup.

Use one shared parser for reader, writer, registry, and native dialect construction. Extend the existing CSV snippet with class, instance, direct-construction, lookup, override, conversion-order, and argument-binding regressions.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 23:28:56 +09:00
youknowdot fe984cec5d select: validate and expand Windows descriptor capacity (#9021)
* Cover Windows select capacity above the SDK default

Add local-socket readiness coverage for 65 entries and the Windows 512-entry limit, preserving 513-entry rejection. This regression-only commit intentionally leaves the current Windows 64-entry defect visible before the implementation is added.

AI assistance covered regression design, CPython 3.14 source comparison, and automated Linux baseline/reference testing. No manual Windows validation is claimed.

Assisted-by: Codex:model-version-unavailable

* Match Windows select capacity to Python 3.14

Use a 512-entry WinSock fd_set with checked C layout and scan its returned socket array. Keep the SDK default-size declaration at the FFI boundary only.

The preceding regression-only commit passed CPython 3.14.7 on hosted Windows and failed RustPython at the first 65-socket selection. Windows-GNU host_env cargo check and Clippy with warnings denied pass. The fixed native Windows runtime result remains pending CI.

AI assistance covered source comparison, implementation, regression design, and automated verification. No manual validation is claimed.

Assisted-by: Codex:model-version-unavailable
2026-10-09 23:25:59 +09:00
youknowdot bd8fdb7e5c Handle math.log bases without premature float conversion (#9019)
Use the natural logarithm path for both operands, evaluating x first. Preserve large integer bases and raise ZeroDivisionError for base one while retaining noninteger conversion errors.

Split the Python 3.14-compatible behavior from #8954 without its additional __index__ fallback or changes to log2 and log10.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 20:56:40 +09:00
youknowdot 48419bd114 Skip overridden items for empty dictionaries in JSON encoding (#9018)
Split the Python 3.14-compatible empty native dictionary fast path from #8954. Extend the existing JSON snippet with root, nested, sorting, and nonempty subclass regression coverage.

Assisted-by: OpenAI Codex:model identifier unavailable
2026-10-09 20:55:36 +09:00
1ndahous3 d0dfcb54e3 Synchronize mmap buffer exports with close and resize (#9015)
* Synchronize mmap buffer exports with close and resize

Assisted-by: Codex:gpt-6

* Keep mmap export checks ahead of data locks

Assisted-by: Codex:gpt-6
2026-10-09 18:29:43 +09:00
youknowdot cd623a9216 Prevent ContextVar cache hits after Context address reuse (#9009)
* Prevent ContextVar cache hits after Context address reuse

Give each Context, including copies, a non-reused cache identity instead
of using its heap address. Disable cache hits if the identity counter
saturates. This prevents an empty Context from reading a destroyed
Context's cached value while preserving existing locking and drop order.

Assisted-by: Codex:model-version-unavailable

* Cover ContextVar reads after context destruction

Exercise fresh and copied contexts with variable defaults, explicit defaults and missing values. The repeated lifecycle check complements canonical context tests without relying on a fixed allocator address-reuse count.

Assisted-by: Codex:model-version-unavailable

* Move ContextVar cache regression into the contextvars snippet

Preserve the fresh and copied Context lifetime checks, defaults and missing-value assertions while removing the redundant Rust interpreter wrapper.

Assisted-by: Codex:model-version-unavailable
2026-10-09 18:27:43 +09:00
youknowdot 98b280109f Return EBADF for negative stat file descriptors (#9008)
* Reject negative file descriptors before fstat

Return EBADF for negative ordinary descriptors before calling rustix, avoiding debug-build assertions on canonical invalid-fd tests. Keep directory-fd sentinel and absolute-path handling unchanged.

Assisted-by: Codex:model-version-unavailable

* Cover negative stat descriptors through the interpreter

Exercise ordinary negative descriptors including values accepted by rustix as directory sentinels, without changing canonical tests or directory-fd parsing.

Assisted-by: Codex:model-version-unavailable

* Move negative stat regression into the os snippet

Preserve the original Unix RustPython-only coverage and every regression assertion while removing the redundant Rust interpreter wrapper. CPython uses -1 as a path sentinel, so keep this regression scoped to its original runtime.

Assisted-by: Codex:model-version-unavailable
2026-10-09 18:27:10 +09:00
1ndahous3 0943b4813b Guard untracked frames against recursive deallocation (#9013)
Assisted-by: Codex:gpt-6
2026-10-09 08:04:25 +09:00
Jeong, YunWon ca9dbb40f8 Give builtin_method its own type (#9004)
Split `builtin_method` out as a subclass of `builtin_function_or_method`.
Ordinary descriptor bind and `__new__` wrappers allocate a CFunction;
only `build_bound_method` uses the METH_METHOD payload. Keep
`types.BuiltinMethodType` as an alias of `BuiltinFunctionType`.

Assisted-by: Grok 4.6
2026-10-08 14:01:52 +09:00
Jeong, YunWon e053f7d5b6 vm: drop trailing space from RecursionError text (#8992)
* vm: drop trailing space from RecursionError text

Format Python-limit and native-stack RecursionError messages
through one helper so empty context is not a trailing space
or an empty string.

Assisted-by: Grok 4.6

* test: deepen nested hash snippets for release stack frames

The cold RecursionError helper thins with_recursion's hot frame,
so 100_000 nested hashes no longer trip the native stack guard
in release.

Assisted-by: Grok 4.6

* vm: let RecursionError callers own the where-clause space

The helper concatenates an empty suffix or one that already
starts with a space. Call sites supply that space.

Assisted-by: Grok 4.6
2026-10-08 00:58:39 +09:00
Jeongseop Lim 95686c08e4 Accept __index__ for the remaining int-bound arguments (#8999)
#8828 made bin(), chr() and several other arguments that were bound
as PyIntRef go through __index__, but these still downcast to int and
reject an object that only defines __index__: the start and end of the
str/bytes/bytearray find family, enumerate(start=),
itertools.combinations/combinations_with_replacement/batched,
_thread.stack_size, resource.getrlimit/setrlimit, pwd.getpwuid,
grp.getgrgid, fcntl.fcntl/lockf and mmap.move/madvise. CPython converts
all of them with _PyNumber_Index or _PyEval_SliceIndex.

Bind them as ArgIndex, as #8828 did for the others.

test_mmap.test_madvise and test_mmap_closed_by_int_scenarios now pass,
so drop their expectedFailure markers.

Assisted-by: Claude Code:claude-opus-5-5
2026-10-07 23:32:59 +09:00
Jeongseop Lim a39d6c9676 Pass round() ndigits to __round__ unchanged (#8997)
round(x, ndigits) ran ndigits through __index__ before calling
__round__, so a user-defined __round__ never saw a non-integer ndigits
and an __index__ object reached it already converted to int. CPython's
builtin_round_impl() forwards ndigits as-is and leaves the conversion
to float.__round__ and int.__round__.

Forward the object, and take ndigits as ArgIndex in both slots so they
apply __index__ themselves. Calling the slots directly with an
__index__ object now works as in CPython instead of raising TypeError.

Assisted-by: Claude Code:claude-opus-5
Assisted-by: Claude Code:claude-opus-5-5
2026-10-07 23:18:55 +09:00
Jiwoo AhnandJeong YunWon ef5c651958 fix: signal.SIGINT and signal() raise NotImplementedError on wasi (#8986)
* fix: signal.SIGINT and signal() raise NotImplementedError on wasi

- Problem: signal.SIGINT and friends don't exist on wasi, and signal.signal()
  is hard-stubbed to raise NotImplementedError there
- Cause: wasi-libc emulates signal()/raise() in a separate opt-in library
  that Rust's own wasm32-wasip1 target distribution doesn't ship
- Fix: vendor wasi-sdk's prebuilt libwasi-emulated-signal.a, link it for
  wasm32-wasip1, and wire SIGINT/SIGABRT/SIGFPE/SIGILL/SIGSEGV/SIGTERM,
  signal()/getsignal()/raise_signal() through it. CPython's own WASI build
  links the same library

Assisted-by: Claude Code:claude-sonnet-5
Signed-off-by: Jiwoo Ahn <ikwydls1314@gmail.com>

* Group WASI signal definitions in mod wasm

Move WASI-only types, constants, FFI, and handlers into
`mod wasm` and re-export them with `#[cfg(target_os = "wasi")]`.

Assisted-by: Grok 4.6

---------

Signed-off-by: Jiwoo Ahn <ikwydls1314@gmail.com>
Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2026-10-07 04:57:13 +00:00
a403341791 Take SyntaxError messages and ranges from the parser (#8983)
* Match CPython's SyntaxError range for unparenthesized `except` types

CPython's `invalid_except_stmt` rule raises the error only once the whole
clause has matched, and reports a range that starts at the first exception
type and ends at the `:` closing the clause, so it covers the `as NAME`
part as well:

    invalid_except_stmt:
        | 'except' a=expression ',' expressions 'as' NAME  ':' {
            RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types
            must be parenthesized when using 'as'") }

The parser reports the exception types alone, so look up that `:` in the
source and widen the range to match. Only `as NAME` may follow the
exception types, which is why the first `:` after them is the one closing
the clause.

    try:
        pass
    except A, B, C as e:
        pass

    CPython 3.14:  ('x.py', 3, 8, 'except A, B, C as e:\n', 3, 20)
    before:        ('x.py', 3, 8, 'except A, B, C as e:\n', 3, 15)

Fixes #8496

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Clarify that the `except` error range stops before the closing colon

`invalid_except_stmt_end` returns the exclusive end of the range, so the
column it yields is the one the `:` sits on even though the `:` is not part
of the range. The previous "ending at the `:`" wording read as if the colon
were included, which invites an off-by-one "fix".

Comments only; no behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Fix the `except ... as` error column for non-ASCII names and line joins

`invalid_except_stmt_end` recovers the end of CPython's range by scanning the
source, which has to redo by hand what CPython gets from its tokenizer:

- The column was the byte distance from the line start, but `end_offset` is a
  character column. `except Ä, B as e:` reported 18 instead of 17. CPython
  converts explicitly, in `_PyPegen_byte_offset_to_character_offset`.
- The colon scan already spans explicit line joins, but the `as` check ran on
  the raw slice, so a `\` before `as` left the range unextended.
  `except A, B \` + `as exc:` reported (3, 12) instead of (4, 7).

Add regression cases to `syntax_invalid.py` covering both, plus the whitespace,
`except*` and line-join placements that already worked. All values are verified
against CPython 3.14.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Update the Ruff fork to 0.16.10

Point the rustpython-ruff_* dependencies at the 0.16.10-rustpython tag
of the RustPython Ruff fork and port to its AST changes:
`ExprCompare` stores all operands in `operands`, call arguments use
`ThinVec`, dict comprehension generators and f-string elements are boxed
slices, `FStringValue` iterates `FStringPartRef`, and `TokenKind::Name`
is now `TokenKind::Identifier`.

Assisted-by: Grok:grok-4.6
Assisted-by: Claude Code:claude-opus-5-5

* Drop the source scan for the `except ... as` error range

The parser now reports the unparenthesized exception types error with a
range ending at the `:` that closes the clause, so
`invalid_except_stmt_end` and the message match that widened the range
are removed.

Assisted-by: Claude Code:claude-opus-5-5

* Take parse error messages from the parser as they are

The Ruff fork now emits the final message texts, so `vm_new.rs` no
longer rewrites parse error messages by matching their text and no
longer lowercases the first character of every message.
`analyze_compile_error` keeps only the caret narrowing for starred
expressions and the line number in the unterminated string message.
The compiler matches the new lowercase texts for indented block and
mixed bytes literal errors.

The fork is referenced by revision until it is published.

Assisted-by: Claude Code:claude-opus-5-5

* Take starred and bytes literal error ranges from the parser

The Ruff fork now reports misplaced starred expressions at the `*` and
non-ASCII bytes literal errors over the whole literal. `vm_new.rs` drops
`narrow_caret` together with `SyntaxErrorInfo`, which only carried the
message after that, and the compiler drops `bytes_literal_span`.

Assisted-by: Claude Code:claude-opus-5-5

* Take indentation error kinds and positions from the parser

The Ruff fork now reports `TabError` and `TooDeepIndentation` as their
own lexer errors and places indentation and line continuation errors
itself. `vm_new.rs` picks TabError or IndentationError from the error
kind instead of scanning the source for mixed indentation, drops the
TabError message override, and sets the end offset of tokenizer errors
to 0 or -1 by kind. The compiler drops the line-end relocation of
unindent errors and the line continuation rewrite. `_tokenize` raises
TabError and depth errors for the token they replace, also for sources
containing tabs.

Remove expectedFailure from test_tokenize.test_max_indent and four
test_tabnanny tests.

Assisted-by: Claude Code:claude-opus-5-5

* Take unterminated string messages from the parser

The Ruff fork's unterminated string errors now include the detected
line and are reported at the start of the string. `vm_new.rs` drops its
message override for `UnclosedStringError`, and the shell continues a
line on an unterminated triple-quoted string by the error's
`triple_quoted` flag instead of reading the quotes from the source.

Assisted-by: Claude Code:claude-opus-5-5

* Take bracket errors and tokenizer error priority from the parser

Bump the ruff fork, which now reports unmatched, mismatched, unclosed
and too deeply nested brackets and decides whether a tokenizer error
replaces the parser's first error.

Remove the bracket, unterminated string and nesting depth source
scanners and `pre_parse_source_error`. A tokenizer error from the
parser now wins over source scanner diagnostics found after it. An
unclosed bracket is incomplete input only when the parser reports it
as such, and other tokenizer errors end where they start.

Remove the expected failure markers from test_unicode_identifiers
test_invalid and the `import ä £` doctest in test_syntax.

Assisted-by: Claude Code:claude-opus-5-5

* Take number literal, string prefix and non-printable errors from the parser

Bump the ruff fork, which now reports malformed number literals,
incompatible string prefixes and non-printable characters itself.

Remove the number literal, string prefix and non-printable character
source scanners and the override classes that ranked them. Leading zero
and string prefix errors keep their range instead of ending where they
start.

Assisted-by: Claude Code:claude-opus-5-5

* Take the missing indented block error from the parser

Bump the ruff fork, which now reports `ExpectedIndentedBlock` with the
clause and the line of its header keyword.

Remove the message rewrite that derived the clause and line from the
source. The VM chooses IndentationError or incomplete input by the
error variant instead of its message.

Assisted-by: Claude Code:claude-opus-5-5

* Take binding target errors from the parser

Bump the ruff fork, which now names the invalid expression in
assignment, augmented assignment, delete, `for`, `with`, import,
pattern and `except` target errors.

Remove the source scanners for those targets and the message rewrites
of `InvalidAssignmentTarget` and `InvalidNamedAssignmentTarget`.
Remove the expected failure markers from test_syntax doctests that now
pass.

Assisted-by: Claude Code:claude-opus-5-5

* Take parameter, argument, star, comma and dictionary errors from the parser

Bump the ruff fork to 36919b62fa. Remove the source scanners for type
parameters, parameter lists, star annotations, call arguments, def type
parameters, parenthesized groups, missing commas and dictionary items.
Set end_offset 0 for ExpectedColonAfterDictionaryKey. Remove 14
EXPECTED_FAILURE markers in test_syntax and test_unpack_ex.

Assisted-by: Claude Code:claude-opus-5-5

* Take expression errors from the parser

Bump the ruff fork to 4f922d2124. Remove the source scanners for
comprehensions, collection and condition assignments, expressions
between strings, named expression targets, missing `in` after for-loop
variables and statements in `if` expressions. Remove the now passing
expected failure markers in test_syntax and test_named_expressions.

Assisted-by: Claude Code:claude-opus-5-5

* Take statement errors from the parser

Bump the ruff fork to c7f6594ed6. Remove the source scanners for
standalone except, `import ... from`, `**_` mapping rests, `elif` after
`else` and mixed except handlers, and the post-parse scanners for call
arguments, match targets, yield after a comma and parenthesized star
imports.

Assisted-by: Claude Code:claude-opus-5-5

* Take string and f-string errors from the parser

Bump the ruff fork to 6b46d0dfc8. Remove the source scanners for
malformed `\N` escapes, f-string and t-string replacement fields, mixed
t-string literals and `print`/`exec` statements, and the override
plumbing they used. Drop the `f'{x'; '` case from the compiler test,
whose expected message differs from CPython 3.14.

Assisted-by: Claude Code:claude-opus-5-5

* Restore the bracket depth check and fix incomplete unclosed strings

Restore `pre_parse_source_error`, which rejects bracket nesting past 200
levels before parsing. The parser reports the same error but still
builds the full tree, which overflows the native stack when dropped.

Remove the VM's unclosed string scanner, which ignored the mode and
treated `'abc` in exec mode as incomplete input. The compiler's check
now skips escaped newlines.

Assisted-by: Claude Code:claude-opus-5-5

* Report multiple statements before later errors in single mode

In single mode, when the first statement is a simple statement, report
code after its line as multiple statements before any error found
later, at the newline token or the comment before it. This replaces the
multiple statements check on the parsed body and also applies to
`ast.parse(mode='single')`.

An unclosed string that follows an earlier syntax error is no longer
incomplete input. The bracket depth error range is now empty.

Assisted-by: Claude Code:claude-opus-5-5

* Update the Ruff fork for parser speed and starred annotations

Bump the ruff fork to 8b59b85344, which skips the tokenizer error pass
when parsing finds no errors, stops allocating for every identifier's
string prefix check, and reports `def f(*args: *b = ...)` as invalid
syntax.

Remove expected failure markers from test_code_module
test_indentation_error and test_sysexcepthook_indentation_error, and
from test_dictcomps test_illegal_assignment.

Assisted-by: Claude Code:claude-opus-5-5

* Use the published Ruff fork 0.16.10 crates

Switch the rustpython-ruff_* dependencies from the git revision to the
0.16.10 crates.io release, published from the same commit (8b59b85344).

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: zzarbttoo <qodbwls70@naver.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 12:54:27 +09:00
5b5c0c7df7 Give dict a CPython-style message for unhashable keys (#8610)
* Give dict a CPython-style message for unhashable keys

Dict operations (subscription, membership, get/pop/setdefault, ...) now
raise "cannot use 'X' as a dict key (unhashable type: 'X')", matching
CPython 3.14 and mirroring the existing PySetInner wrapping. The key is
only materialized on the error path, so hashable keys pay no extra cost.

Enables Lib/test/test_dict.py::DictTest::test_unhashable_key.

Assisted-by: Claude Opus 4.8 (Anthropic)

* dict: only rewrite hashing failures, not key-comparison errors

wrap_unhashable_error previously rewrote any TypeError from a dict
operation as an unhashable-key error, but those operations also compare
keys on a hash collision, so a TypeError from a colliding key's __eq__
was mislabeled. Disambiguate on the error path by re-hashing the key, so
the successful path still hashes exactly once (keeps the do-not-rehash /
atomic invariants) while comparison errors propagate unchanged.

Adds a colliding-key regression test.

Assisted-by: Claude Opus 4.8 (Anthropic)

* dict: hash unhashable keys once up front and cover every insertion path

Addresses the review feedback (thanks @luantaraschi):

- The message now reaches update(), the constructor and |= as well, not just
  __setitem__: merge_object_with_override and merge_from_seq2 now hash the key
  up front and thread it into contains_known_hash/insert_known_hash.
- Hash the key once instead of re-hashing on the error path. This threads the
  hash through the *_known_hash operations (add dict_inner get_known_hash), so
  a __hash__ that fails only on its first call is still reported instead of
  escaping unwrapped.
- Use the fully-qualified type name (matching CPython's %T).
- Only an exact TypeError is rewritten; a __hash__ raising a TypeError subclass
  now propagates unchanged.

pop() and setdefault() have no *_known_hash entry point on the inner map, so
they hash once up front for the message and then do their own single lookup.

Assisted-by: Claude Opus 4.8

* dict: thread the known hash through setdefault and pop as well

Follow-up on the review: setdefault() and pop() previously hashed the key a
second time (inside the inner map) after hash_or_unhashable already hashed it,
so a stateful __hash__ failing on the second call would skip the dict-specific
message. Add setdefault_known_hash / pop_known_hash to the inner map and thread
the precomputed hash, so every operation now hashes exactly once. Adds a
regression test asserting setdefault/pop call __hash__ only once.

Assisted-by: Claude Opus 4.8

* test: hash the key on a non-empty dict so CPython 3.14 exercises the pop path

`{}.pop(CountingHash())` on an empty dict does not hash the key under
CPython 3.14 (the lookup short-circuits), so `CountingHash.calls == 1` was 0
and the snippet failed its CPython parity run. Use a non-empty dict so the
lookup must hash the key exactly once, on both CPython and RustPython. Also
applied `ruff format` (two blank lines before top-level defs).

Assisted-by: Claude Opus 4.8 (Anthropic)

* dict: drop unused internal pop wrapper

Per review, the vm-taking Dict::pop wrapper was dead code (#[allow(dead_code)],
kept only for API symmetry) with no callers. Remove it and fold its doc into
pop_known_hash.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* dict: rename pop_known_hash to pop

Per review, with the plain pop gone the _known_hash suffix no longer earns
its keep, so drop it. Matches the remaining known-hash helpers that still
pair with a base method.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* dict: fold setdefault wrapper into setdefault, drop unused setdefault_entry

Per review, apply the same pattern as pop: the dead setdefault wrapper only
hashed and delegated, so remove it and rename setdefault_known_hash to
setdefault (callers already thread the hash). Also drop setdefault_entry,
which this PR added but nothing uses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* dict: use set_cause and Result from fully_qualified_name

After rebasing onto main, fully_qualified_name returns PyResult
and set___cause__ is a private Python setter.

Assisted-by: Grok:4.6

* dict_inner: take a hash for every key operation

Drop the hashing wrappers and *_known_hash aliases. Callers hash
the key and pass it in.

Assisted-by: Grok:4.6

* snippets: add blank line before BadEq class

ruff format requires two blank lines before a top-level class.

Assisted-by: Grok:4.6

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2026-10-06 00:24:42 +09:00
Hanjeong Lee 3126762358 Give os.chmod a valid __text_signature__ and keyword arguments (#8968)
* Order chmod's arguments the way CPython declares them

posix.chmod took dir_fd between path and mode. Since #8807 renders
each argument's parameter kind, that put `/` after `*`, which inspect
cannot parse, and path and mode stayed positional-only, so
os.chmod(path=..., mode=...) raised TypeError.

A ChmodArgs struct follows CPython's order, as nt.chmod already does.
path and mode are positional-or-keyword. follow_symlinks shows
CPython's text through py_default, like LinkArgs.

Assisted-by: Claude Code:claude-opus-5

* Reject a text signature that puts `/` after `*` or `**`

The writer counts positional-only parameters up front and emits `/`
when they run out, which assumes they come first in the Rust argument
list. Nothing enforced that, and posix.chmod violated it. The
signature is composed in a const context, so the assert fails the
build and names the fix.

Assisted-by: Claude Code:claude-opus-5
2026-10-06 00:13:55 +09:00
youknowdot d3ff1eb5ea Keep module cache entries present during import reordering (#8948)
* Reorder the module cache atomically during imports

Add a private exact-dict move primitive and importlib dispatcher so shutdown-order updates never temporarily remove a module. Preserve current values and custom-mapping fallback behavior; validate reentrant equality probe witnesses, invalidate layout caches, and compact moved entries.

Cover all four existing bootstrap reorder sites, including legacy-loader cleanup. Add deterministic trace-window, loader replacement/removal, reentrancy, cache, iterator and compaction regressions. The private native primitive uses true-move semantics; it does not promise arbitrary pop/set callback equivalence.

Assisted-by: Codex:model-version-unavailable

* Keep atomic import regression compatible with modern bootstrap

Run legacy-loader cases when the bootstrap exposes that helper, preserving all four 3.14 paths and the two remaining 3.15 paths. Always retain modern load and exec regressions.

Assisted-by: Codex:model-version-unavailable

* Keep the copied bootstrap unchanged in the native relocation PR

Restore the exact CPython 3.14 bootstrap and retain only the private exact-dict relocation primitive and its direct native regressions. Remove the PR-added callback integration tests while preserving native helper assertions. This prepares a primitive only; imports do not call it and the import race remains unresolved.

Assisted-by: Codex:model-version-unavailable
2026-10-05 20:48:57 +09:00
8e581e6cd5 Truncate sequence index TypeError names to 200 characters (#8967)
* Match CPython's str subscript TypeError message

`str.__getitem__` with a non-index key raised the shared sequence
wording ("str indices must be integers or slices or classes that
override __index__ operator, not 'x'") instead of CPython's
str-specific "string indices must be integers, not 'x'" (bpo-44110 /
gh-88276, Python 3.11).

Add `SequenceIndex::try_from_borrowed_object_with_err`, which takes a
caller-supplied error closure, and have the existing
`try_from_borrowed_object` delegate to it with the unchanged shared
message. `str._getitem` now supplies the CPython-accurate message,
which flows through both `__getitem__` and the mapping subscript slot.
Other sequence types keep the shared wording.

Removes the expectedFailure marker on
`string_tests.StringLikeTest.test_subscript`, fixing it for both
test_str and test_userstring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Fold str's subscript TypeError into the shared index helper

The previous commit added `SequenceIndex::try_from_borrowed_object_with_err`
(a closure-taking function) so `str` could raise CPython's
"string indices must be integers, not ..." message. Per review, a whole
helper API plus a thin wrapper was overkill for a single caller.

Instead, inline that one error case into `try_from_borrowed_object`: when
`type_name` is "str", raise the str-specific message; every other type keeps
the shared sequence wording. `str._getitem` goes back to the plain `match`
over `SequenceIndex` with no duplicated index parsing. A bad slice key
(e.g. `'a'[::'x']`) still surfaces the slice-specific error, since only the
non-index/non-slice branch is customized.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Truncate index TypeError type names to 200 characters

Route str's non-index TypeError through a function pointer
message helper. Sequence index errors use the same 200-character
type-name cap.

Assisted-by: Grok:4.6

* Encode sequence index TypeError names as type params

`&'static str` cannot be a const generic. SequenceIndexName
holds the name as an associated constant, matching ArgName.
Both str and sequence errors go through one fn(&str) -> String
and a cold TypeError helper.

Assisted-by: Grok:4.6

---------

Co-authored-by: Jaedeok Kim <rn.6d17s2@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-05 18:52:52 +09:00
youknowdot 04d9990616 Add the eager-runtime hook required by Python 3.15 importlib (#8946)
* Add the eager-runtime importlib lazy-attribute hook

Expose _imp._set_lazy_attributes(modobj, name, /), used by CPython 3.15 importlib after eager loading. Match its empty pending-lazy-module registry behavior, including name type and string-subclass hashing checks. This does not implement lazy imports or change the target version or bundled libraries.

Assisted-by: Codex:model-version-unavailable

* Consolidate lazy import hook tests into stdlib_imp

Move the distinct direct-hook argument and hashing contracts into the existing _imp snippet and remove the separate file. Preserve every pre-existing assertion and the CPython version guard; canonical 3.15 lazy-import tests already cover feature-level registry and reification behavior.

Assisted-by: Codex:model-version-unavailable
2026-10-05 08:29:00 +00:00
youknowdot f46ba48f10 Preserve callable addresses in ctypes function pointer casts (#8965)
Read the stored executable address when casting a function pointer and accept function pointer types as cast destinations. The existing ownership dictionary retains the original callback through a cast roundtrip.

Extracted independently on the unchanged Python 3.14 target, without typed callback argument or broader py_object transport changes. One unique callback-address/ownership regression extends the existing ctypes snippet; canonical coverage was checked for duplicates.

Assisted-by: Codex:model-version-unavailable
2026-10-05 15:23:22 +09:00
1ndahous3 e5f332fda4 Release interpreter channel payloads outside internal locks (#8964)
Assisted-by: Codex:gpt-6
2026-10-05 09:43:04 +09:00
youknowdot 5a61850e32 Use populated entries for unpickler MEMOIZE indexes (#8959)
* Use populated entries for unpickler MEMOIZE indexes

A sparse BINPUT followed by MEMOIZE must use the number of occupied memo
entries, not the largest index plus one. Store populated entries in a map,
preserve ascending memo copies, reserve fallibly, and release displaced
references after memo guards end.

Keep existing memo assignment/proxy behavior and add one bounded regression
for sparse BINPUT, MEMOIZE identity and copy order. No protocol version,
GC traversal or unrelated pickle input changes are included.

Extracted from the Python 3.15 migration onto the unchanged 3.14 target.

Assisted-by: Codex:model-version-unavailable

* Move sparse memo regression to standard pickle snippet

Use the module-level snippet name requested in review without changing the regression assertions.

Assisted-by: Codex:model-version-unavailable
2026-10-05 09:03:52 +09:00
Chanho Lee 7536730ed6 Fix store subscr list finalizer deadlock (#8956)
* Release replaced list item outside the lock in STORE_SUBSCR_LIST_INT

Assisted-by: Claude Code:claude-opus-5-5

* Add a snippet for finalizers reading a list during a specialized store

Assisted-by: Claude Code:claude-opus-5-5
2026-10-04 22:47:45 +09:00
1ndahous3 112b7efa80 Promote retained GC objects and batch generation updates (#8930)
Assisted-by: Codex:GPT-6
2026-10-02 01:42:09 +09:00
Jeong, YunWon cb0f3b012b Add a native _zoneinfo module (#8915)
* Add a native _zoneinfo module

ZoneInfo reads TZif tuples from zoneinfo._common.load_data. The stdlib
module implements utcoffset, dst, tzname, fromutc, and the zone cache.
whats_left compares that class. Cache tests no longer expect failure.

Assisted-by: Grok:grok-4.7

* Fix ZoneInfo layout and keep its cache on the module

utcoffset, dst, and tzname take the object. Zone data is boxed so the
payload lines up with tzinfo on 32-bit. The strong, weak, and timedelta
caches live on each interpreter's _zoneinfo module.

Assisted-by: Grok:grok-4.7
2026-10-01 11:32:32 +09:00
Jean-Marc Le Roux 3805038dec zlib: clear unconsumed_tail when a bounded decompress reaches stream end (#8908)
* zlib: clear unconsumed_tail when a bounded decompress reaches stream end

When a max_length-bounded Decompress.decompress() call reached the end
of the stream, the bytes after the stream went to unused_data, but
unconsumed_tail kept the previous call's tail, including input the call
had already consumed. A later flush() then moved those stale bytes into
unused_data.

Empty unconsumed_tail at end of stream, as CPython's
save_unconsumed_input() does since gh-158169. CPython releases before
that change report the bytes after the stream in unconsumed_tail, so
the snippet accepts either value when it runs under CPython.

Fixes #8906

Assisted-by: Claude Code:claude-opus-5-5

* zlib: bind the unconsumed input with an if expression

Choose between the empty slice and the rest of the input in one
expression instead of reassigning a mutable binding.

Assisted-by: Claude Code:claude-opus-5-5

* zlib: accept both valid tails in the snippet on every implementation

The snippet no longer branches on sys.implementation. RustPython and
CPython after gh-158169 give an empty tail; CPython before it gives the
bytes after the stream. The stale tail of gh-8906 fails either way.

Assisted-by: Claude Code:claude-opus-5-5
2026-09-30 22:15:40 +09:00
1ndahous3 e8919b9632 Preserve list mutation progress and release removed items outside locks (#8894)
* Preserve list mutation progress and release removed items outside locks

Assisted-by: Codex:GPT-6

* Trim excessive list extension reservations

Assisted-by: Codex:GPT-6
2026-09-30 22:14:47 +09:00
Sumi Jeong c9c78db91c Bound AST nesting so deep source raises instead of crashing (#8827)
* Bound AST nesting so deep source raises instead of crashing

Deeply nested source exhausted the native stack and killed the process
with SIGSEGV, which no Python-level `except` can catch.

The parser grows its own stack when it runs low on one, so it returns
trees deeper than the passes after it can walk. Those passes recurse
without a limit of their own, and the symbol table, which does apply
one, runs last. `compile(..., PyCF_ONLY_AST)` returns before reaching
it at all.

Apply that same limit to the tree right after it is parsed, and count
bracket nesting before parsing rather than after, as CPython's
tokenizer does. Checking afterwards built the tree first, and one
nested that deep exhausts the stack when it is dropped.

Fixes #7655

Assisted-by: Claude Code:Opus 5

* Return Result from too_deeply_nested_error

Lets the four call sites use `?` instead of matching on `Some` and
returning the error by hand, which drops 11 lines. `Result` is already
`#[must_use]`, so the attribute on the function goes away with it.

Assisted-by: Claude Code:Opus 5

* Return Result from pre_parse_source_error too

Same shape as the previous commit, for the other check this PR adds, so
the two are consistent with each other.

Assisted-by: Claude Code:Opus 5

* Drop exceeds_max_nesting for the check beside it

The escape-warning pass needs the bracket check but had no `SourceFile` to
build a `CompileError` from, so it got a `bool` wrapper of its own. Building
the `SourceFile` there lets it call `pre_parse_source_error` instead, which
is shaped like the other checks in that file, and costs nothing measurable.

Assisted-by: Claude Code:Opus 5
2026-09-30 22:13:15 +09:00
1ndahous3 74019cf627 Update concurrent.futures for Python 3.14 (#8904)
* Update concurrent.futures for Python 3.14

Assisted-by: Codex:GPT-6

* Enable relative import completion test

Assisted-by: Codex:GPT-6
2026-09-30 02:16:15 +09:00
1ndahous3 ea76251294 Cache parsed struct formats per interpreter (#8903)
* Cache parsed struct formats per interpreter

Assisted-by: Codex:GPT-6

* Preserve struct cache entries on concurrent misses

Assisted-by: Codex:GPT-6
2026-09-30 02:13:21 +09:00
Alessio Attilio d857eebdce fix(gc): traverse annotate name and qualname fields in PyFunction (#8839)
* fix(gc): traverse annotate name and qualname fields in PyFunction

* style: format extra_tests/snippets/stdlib_gc.py

Assisted-by: Antigravity:Gemini-3.8-Flash
2026-09-29 11:49:59 +09:00
1ndahous3 f909d2a30d Add native _datetime module (#8872)
* Add native _datetime module

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Codex:GPT-6

* Use pymember and safe timezone storage in datetime

Assisted-by: Codex:GPT-6
2026-09-29 11:45:11 +09:00