Commit Graph
4784 Commits
Author SHA1 Message Date
Jeong, YunWon d77b80daed Implement round-half-even float.fromhex in common float_ops (#8234)
* Add round-half-even hex float parser to common float_ops

Add float_ops::from_hex returning Result<f64, HexFloatError>, which parses
the coefficient and exponent, rounds round-half-even over the full exponent
range, and detects overflow. Route float.fromhex through it: raise
OverflowError for values too large to represent and ValueError for invalid
input. Remove the expectedFailure on test_from_hex.

Assisted-by: Claude

* Address review: Option-returning byte helpers, const fns, drop test_ prefix

Assisted-by: Claude

* Whitelist fdigits and inity in cspell

Assisted-by: Claude

* Home is_py_ascii_whitespace in rustpython-wtf8; share with common and sre_engine

Assisted-by: Claude

* Use shared wtf8 is_py_ascii_whitespace in bytes_inner

Remove the private copy of is_py_ascii_whitespace in bytes_inner.rs and
import the shared rustpython_common::wtf8::is_py_ascii_whitespace.

Assisted-by: Claude
2026-07-08 10:03:29 +09:00
Jeong, YunWon 55c012cffd unicode crate (#8211)
* Extract unicodedata core into rustpython-unicode crate

Move the vm-free Unicode character database access — the generated UCD 3.2.0 /
latest tables, their build-time generation, and the icu4x/unicode_names2 lookups
for category/bidirectional/combining/east_asian_width/mirrored/decomposition/
normalize/is_normalized/digit/decimal/numeric/name/lookup — into a new leaf crate
over char/CodePoint/&Wtf8. stdlib/unicodedata.rs keeps the UCD pyclass binding: it
extracts the code point, boxes results, and maps errors. The unicode data files,
build.rs table generation, and the icu_properties/icu_normalizer/unicode_names2
dependencies move out of stdlib.

Assisted-by: Claude

* Route str predicates, casefold, and printable through rustpython-unicode

Add classify/case/identifier modules to the shared crate over char/&str/&Wtf8:
isalpha/isalnum/isdecimal/isdigit/isnumeric/isspace/isprintable classification,
XID identifier predicates, and full-mapping casefold. vm/builtins/str.rs and
literal/char.rs now call these instead of icu_properties/icu_casemap directly.
String-level iteration with final-sigma handling (lower/upper/title/capitalize,
islower/isupper) stays in the runtime.

Assisted-by: Claude

* Route sre_engine char classes through rustpython-unicode

Add the regex module with the SRE character-class and case predicates
(is_word/is_space/is_digit, is_uni_* Unicode variants, ascii/locale/unicode case
folding). sre_engine/string.rs now forwards to it, keeping its public API and
behavior identical — including the ASCII-only is_uni_digit and the hardcoded
is_uni_space table.

Assisted-by: Claude

* Route \N{} name lookups through rustpython-unicode

codegen/string_parser.rs (\N{...} escapes) and common/encodings.rs (the
namereplace error handler) now resolve character names via rustpython-unicode
instead of depending on unicode_names2 directly, leaving the crate as the sole
owner of the name database.

Assisted-by: Claude

* Add differential Unicode sweep and shared-crate snippet test

tests/differential.rs sweeps the full 0..0x110000 range and compares each str
classification predicate against a committed CPython 3.14 reference dataset
(tests/data/cpython3.14_predicates.txt, produced by generate_reference.py). Code
points that differ only because the Rust std / icu4x build ships a later Unicode
release than CPython 3.14's 16.0.0 are recorded in
tests/data/version_skew_cpython3.14.txt, regenerable via
RUSTPYTHON_UNICODE_REGEN_SKEW=1; the regen refuses to record any
cpython=true/crate=false divergence, so only newly-assigned code points are
allowed. Any other divergence fails. Both data files use a run-length
`predicate start:end,...` encoding.

extra_tests/snippets/stdlib_unicode_shared.py exercises the routed surface end to
end (str predicates, casefold, identifiers, unicodedata, normalize, \N{}, and re
character classes) and passes identically on CPython 3.14 and RustPython.

Assisted-by: Claude

* Match regex \d to Unicode decimal digits

is_uni_digit previously matched only ASCII 0-9, so re's \d in Unicode mode
missed decimal digits like ٥ and ५. SRE_UNI_IS_DIGIT matches Py_UNICODE_ISDECIMAL
(category Nd), so route it through classify::is_decimal. Unmasks test_bug_6561 in
test_re and extends the shared-crate snippet with the Nd/Nl/No cases.

Assisted-by: Claude

* Replace shallow Unicode wrappers with re-exports

Address review feedback on the extraction.

Functions that only forwarded to the shared crate become `use ... as`
re-exports rather than hand-written wrappers:

- literal: is_printable is dropped; escape.rs calls
  rustpython_unicode::classify::is_repr_printable directly.
- unicode::identifier::is_continue re-exports is_xid_continue.
- unicode::data::lookup_character re-exports unicode_names2::character.
- Drop the unused repr(u8) on DecompositionType.

The SRE character-class and case predicates move back into
sre_engine::string (their pre-extraction home) instead of living in a
unicode::regex module that only sre_engine and the vm _sre binding used;
is_uni_digit/is_uni_alnum still delegate to rustpython_unicode::classify.
engine.rs and _sre consume them from sre_engine::string again.

The unicode crate's tests move from a single root tests module in lib.rs
into per-module test submodules (case, classify, data, identifier,
normalize).

Assisted-by: Claude

* no-std

* Address review feedback: test module, dead variant, WTF-8 normalization

- differential.rs: move the sweep tests into a `mod tests` block and drop
  the file-level allow of clippy::tests_outside_test_module and
  std_instead_of_alloc; the test uses alloc collections instead.
- data.rs: remove the never-constructed DecompositionType::Canonical variant
  and its allow(unused); compatibility decomposition never produces it and
  canonical decomposition is handled through icu4x.
- normalize.rs: is_normalized now takes &Wtf8 and checks each UTF-8 run,
  skipping lone surrogates, matching normalize's run-wise behavior.
- unicodedata.rs: pass as_wtf8() to is_normalized.

Assisted-by: Claude
2026-07-07 09:19:25 +09:00
Shahar Naveh 0664e38e5b Set python args to be like CPython in CI (#8181)
* Set python args to be like CPython in CI (ish)

* Use `--slow-ci`

* `--dont-add-python-opts`

* unmark passing test
2026-07-06 23:52:33 +09:00
Kwak Byoung Min 8bdc1cc5fd Fix csv.writer QUOTE_NONE with quotechar=None (#8201)
* Prevent csv QUOTE_NONE writer panics without quotechar

Handle csv.writer rows with QUOTE_NONE through a RustPython-owned unquoted writer path so quotechar=None no longer reaches the unfinished csv_core configuration branch. Escape delimiter, newline, quotechar, and escapechar bytes according to the active dialect, and preserve CPython's single-empty-field error behavior.

Constraint: Match CPython csv.writer behavior without changing Lib/ copied stdlib files.
Rejected: Relying on csv_core QuoteStyle::Never | it does not model CPython QUOTE_NONE escaping with quotechar=None.
Confidence: high
Scope-risk: narrow
Directive: Keep QUOTE_NONE writer behavior separate unless csv_core gains matching CPython semantics.
Tested: prek run --all-files; cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher; cargo build --release --features sqlite; pytest -v in extra_tests
Assisted-by: Codex:gpt-5.5

* Keep csv parity tests aligned with QUOTE_NONE support

Remove the stale RustPython expected-failure marker for the CPython escaped-field writer test that now passes, and cover CR/LF escaping in the snippet regression requested during review.

Constraint: RustPython test policy allows removing expectedFailure markers only when the upstream test passes.

Rejected: Refactoring writer row boilerplate in this follow-up | review marked it as a heavy-lift nitpick and it would broaden the CI fix.

Confidence: high

Scope-risk: narrow

Tested: cargo run --release --features sqlite -- -m test test_csv; cargo run -- extra_tests/snippets/stdlib_csv.py; PATH=/tmp/pyshim:$PATH prek run --all-files; git diff --check; cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher; pytest -v in extra_tests

Assisted-by: Codex:gpt-5.5

* Keep csv quote-style dispatch coherent

Review feedback pointed out that adjacent branches selected behavior from the same quoting discriminator. Use one match so future quote-style additions are routed in a single place.

Constraint: RustPython review requested merging adjacent quote-style checks.
Confidence: high
Scope-risk: narrow
Tested: cargo fmt --check
Tested: target/release/rustpython extra_tests/snippets/stdlib_csv.py
Tested: target/release/rustpython -m test test_csv
Tested: PATH=/tmp/pyshim:$PATH prek run --all-files
Tested: RUST_TEST_THREADS=1 cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher -- --test-threads=1
Tested: cargo clippy --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --all-targets
Assisted-by: Codex:gpt-5.5
2026-07-05 01:17:46 +09:00
Shahar Naveh b39bec4063 Align symtable flag names with CPython (#8184)
* ASSIGNED -> DEF_LOCAL

* GLOBAL -> DEF_GLOBAL

* REFERENCED -> USE

* PARAMETER -> DEF_PARAM

* expose symbol flags directly as a pyattr

* FREE_CLASS -> DEF_FREE_CLASS

* IMPORTED -> DEF_IMPORT

* ANNOTATED -> DEF_ANNOT

* DEF_COMP_ITER DEF_COMP_CELL DEF_TYPE_PARAM

* DEF_NONLOCAL DEF_BOUND

* Align flag values

* unmark passing tests
2026-07-02 16:41:31 +09:00
Shahar Naveh 16869e1ce8 Update some tests to 3.14.6 (#8204)
* Apply skip at the correct place

* Update `test_msvcrt.yp` to 3.14.6

* Add `test_external_inspection.py`
2026-07-02 16:32:33 +09:00
Shahar Naveh d93dd2a781 Update test_sqlite3 to 3.14.6 (#8172) 2026-06-30 23:49:27 +09:00
Shahar Naveh a588a64572 Uncomment codegen crashing tests (#8175)
* Update `test_patma.py` to 3.14.6

* Update `test_listcomps.py`

* Align patches of `test_super.py`

* Align `test_grammar.py`

* Align patches for `test_pep646_syntax.py`
2026-06-30 23:32:30 +09:00
Shahar Naveh 9c027d4f67 Update test/signalinterproctester.py to 3.14.6 (#8173)
* Update `test/signalinterproctester.py` to 3.14.6

* Add `signalinterproctester.py` as a test dependency of `test_signal.py`
2026-06-26 18:24:20 +09:00
Shahar Naveh 8cb96ebcbb Update test_subprocess.py to 3.14.6 (#8171) 2026-06-26 18:23:54 +09:00
Jeong, YunWon a1ba6a662c Align compiler and AST behavior with CPython (#8138)
* Align compiler and AST behavior with CPython

Update the compiler pipeline, AST module support, and related VM compile/eval paths toward CPython 3.14 behavior.

Use upstream Ruff parser crates directly and keep RustPython-specific syntax preflight handling in the compile path.

Refresh opcode metadata, snapshots, and targeted tests for the aligned bytecode and AST behavior.

* fix

* Fix PR 8138 CI failures

* Fix match mapping wildcard scan complexity

* fixes

* Use Ruff runtime AST fields

* Minimize residual patch diff

* refactor error handling

* Remove _ast conversion context wrappers

* Clean up _ast conversion glue and compiler warning escalation

Rename the Node conversion parameter `ctx` to `vm` throughout the _ast
module.

Remove the unused compile_program, compile_program_single,
compile_block_expression, and compile_expression forwarders; compile_top
stays as the entry point.

Stash an escalated compiler SyntaxWarning so a non-SyntaxWarning category
propagates unchanged instead of being rewritten to SyntaxError, matching
PyErr_ExceptionMatches(SyntaxWarning) in compiler_warn. Drop the now-unused
CompileWarningError::into_codegen_error.

Replace the PositionalArguments two-variant enum with a struct holding a
shared range and a PositionalArgumentsKind enum.

Assisted-by: Claude

* Represent compiler flags as a CompilerFlags bitflags

Replace the loose PY_CF_*/CO_* i32 constants in compile_mode with a
CompilerFlags bitflags covering the PyCF_* flags and __future__
CO_FUTURE_* bits. The Python-visible ast.PyCF_* attribute values are
derived from it via bits(); parser input modes stay plain consts.

builtins::compile and the compile_string flag handling test flags
through CompilerFlags::contains instead of raw bit math.

Assisted-by: Claude

* Fix PR 8138 test regressions

* Fix PR 8138 CI failures

* Avoid shell interpolation in Linux deps action

* Fix review findings in compiler/AST changes

- frame.rs: compute the MATCH_CLASS class name lazily so a successful
  match no longer takes the type name lock or allocates; the
  __match_args__-not-a-tuple branch reuses it instead of recomputing.
- _ast/constant.rs: add the missing leading space to the with_recursion
  label ("maximum recursion depth exceeded during compilation").
- sys.set_int_max_str_digits: restore the "maxdigits must be 0 or larger
  than {n}" error text.
- codegen: set CO_MAXBLOCKS to 20 in both ir.rs and compile.rs.
- _ast/exception.rs: extract the duplicated excepthandler node guard
  into ensure_excepthandler_node.
- codegen: correct the validate_keywords doc comment.
- Drop redundant "CPython" qualifiers from comments added in this branch.

Assisted-by: Claude
2026-06-26 18:22:08 +09:00
Shahar Naveh b28f29313f Update some tests to 3.14.6 (#8167)
* Add `test_fileutils.py` from 3.14.6

* Align patch for `test_zipimport_support.py`

* Update `test_bigmem.py` to 3.14.6

* Update `test_exception_group.py`

* Align patches for `test_baseexception.py`

* Update `test_exceptions.py`

* Update `test_dtrace.py`

* Remove patch from `string_tests.py`
2026-06-25 22:33:51 +09:00
Shahar Naveh 7edb4fb016 Update test_ssl.py to 3.1.46 (#8166)
* Update `test_ssl.py` to 3.14.6

* Add `Lib/test/ssltests.py`

* Mark failing test correctly
2026-06-25 22:33:13 +09:00
Shahar Naveh 7b715541be Update test_tempfile.py to 3.14.6 (#8165) 2026-06-25 22:32:57 +09:00
Shahar Naveh a807620fc1 Update test_repl.py to 3.14.6 (#8164)
* Update `test_repl.py` to 3.14.6

* mark failing tests

* Mark failing test correctly
2026-06-25 22:32:44 +09:00
Shahar Naveh e4814d4893 Update ensurepip to 26.1.2 (cpython 3.14.6) (#8163) 2026-06-25 22:25:32 +09:00
Shahar Naveh 7350a5b709 Implement collections.defaultdict in rust (#8132) 2026-06-23 22:47:10 +09:00
Shahar Naveh 221d95cbbe Run windows tests with -u all (#8134)
* Enable all test resources on windows

* Mark tests

* mark wmi test
2026-06-22 16:46:53 +09:00
Shahar Naveh 866f7ca812 Fix symtable type_param_block name (#8137) 2026-06-22 16:44:08 +09:00
Shahar Naveh 432df16bdd Align patches at test_types.py (#8126)
* Align patches at `test_types.py`

* Add missing methods for `_io.TextIOBase`
2026-06-22 16:30:23 +09:00
Shahar Naveh 80d392ddc3 Skip flaky test at test_thread.py (#8125) 2026-06-22 16:28:35 +09:00
Shahar Naveh 5893c688c9 Fix builtin class names not being interned (#8116) 2026-06-16 17:15:01 +09:00
Rory Yorke e65b1fc488 Dedent -c command-line parameter value (#8056) 2026-06-16 15:58:12 +09:00
Shahar Naveh a1eeee28e4 Update idlelib to 3.14.6 (#8105)
* Update `idlelib/` to 3.14.6

* Update `test_idle.py` to 3.14.6
2026-06-15 11:21:28 +09:00
Shahar Naveh 7da696661b Reduce number of string clones when compiling python source code (#8103) 2026-06-15 11:20:48 +09:00
Shahar Naveh a1355939d2 Update some libs to 3.14.6 (#8102) 2026-06-15 11:20:13 +09:00
Shahar Naveh 4da8a1f1d3 Update xml to 3.14.6 (#8101)
* Update `xml` to 3.14.6

* Update tests

* mark failing tests

* Align patches
2026-06-15 11:19:40 +09:00
Shahar Naveh 79c3575961 Update libregtest to 3.14.6 (#8100)
* Update `test_regrtest.py` to 3.14.6

* Update `libregrtest`

* Update unittest

* Unmark passing test

* Remove `test_set` from env polluters

* Revert "Unmark passing test"

This reverts commit 82b8c1c228.

* Revert "Remove `test_set` from env polluters"

This reverts commit 5a4040da32.

* Mark failing test
2026-06-15 11:19:01 +09:00
Shahar Naveh d758d60eb1 Newtype SigalNum (#8096)
* Newtype SigalNum

* impl Index<SigalNum> for SignalHandlersInner
2026-06-15 11:12:39 +09:00
Joshua Megnauth 5c1803e019 Fix most of unicodedata; unmask multiple tests (#7947) 2026-06-14 17:47:42 +09:00
Shahar Naveh 5d375e3c21 Update some of changed libs and tests from 3.14.5 -> 3.14.6 (part 3) (#8086) 2026-06-12 23:50:07 +09:00
Shahar Naveh b8776bd8d0 Update some of changed libs and tests from 3.14.5 -> 3.14.6 (part 2) (#8085) 2026-06-12 23:49:47 +09:00
Shahar Naveh a2fabfa064 Update some of changed libs and tests from 3.14.5 -> 3.14.6 (part 1) (#8084) 2026-06-12 23:49:15 +09:00
Shahar Naveh 3ff976180a Update pyrepl to 3.14.5 (#7823)
* Add a dummy `posix._is_inputhook_installed` function

* Add a dummy `nt._is_inputhook_installed` function

* Update `_pyrepl` to 3.14.5

* Update `test_pyrepl` to 3.14.5

* Add a dummy `posix._is_inputhook_installed` function
2026-06-12 11:10:50 +09:00
Shahar Naveh beb8d6070e TODO: Flaky test -> TODO: RUSTPYTHON; Flaky test (#8078) 2026-06-12 11:09:44 +09:00
Shahar Naveh 3a4e82973d Skip flaky asyncio tests (#8075)
* Skip flaky test on windows

* Skip another flaky test
2026-06-11 18:45:34 +09:00
Shahar Naveh 832f782906 Don't skip test in test_tempfile.py on all platforms (#8067) 2026-06-11 18:11:30 +09:00
Shahar Naveh 8585981dda Update some tests to 3.14.5 (#8072)
* Update `test_poll.py` to 3.14.5

* Update `test_utf8_mode.py` to 3.14.5

* Align patches for `test_unpack.py`
2026-06-11 13:36:51 +09:00
Shahar Naveh 4632174257 Don't skip test in test_typing.py (#8073) 2026-06-11 13:36:40 +09:00
Shahar Naveh f1dd42e066 Update pdb.py to 3.14.5 (#8070)
* Update `pdb.py` to 3.14.5

* Add `test_pdb.py` from 3.14.5

* Update `_pyrepl/types.py`

* Update `_pyrepl/utils.py`

* Mark failing tests

* Mark failing tests
2026-06-11 13:36:30 +09:00
Shahar Naveh c5dcfa239d Remove stale patches from test_traceback.py (#8068) 2026-06-11 12:49:08 +09:00
Shahar Naveh c27df40225 Conditionally skip test_pty tests (#8066) 2026-06-11 12:15:41 +09:00
Shahar Naveh 984d936ed6 Fix test_tty.py tests (#8065)
* Align patches of `test_tty`

* Fix failing tests at `test_tty.py`

* Align patches of `test_termios.py`

* Unmark passing tests under `test_termios.py`

* Unmark another passing test
2026-06-11 12:15:21 +09:00
Shahar Naveh 697bde31c9 Skip flakey windows test (#8063) 2026-06-11 12:12:33 +09:00
Shahar Naveh c6a55356b5 Update test_code.py to 3.14.5 (#8054)
* Update `test_code.py` to 3.14.5

* skip flakey ci test
2026-06-10 11:14:47 +09:00
Shahar Naveh 7060fe3b5b Add _blake2 consts (#8053)
* Add `_blake2` consts

* Update `test_hashlib.py` to 3.14.5
2026-06-10 11:14:05 +09:00
Shahar Naveh da99e72771 Update test_sys{log,_settrace}.py to 3.14.5 (#8030)
* Update `test_syslog.py` to 3.14.5

* Update `test_sys_settrace.py` to 3.14.5
2026-06-03 22:51:41 +09:00
Shahar Naveh fe6b9e8403 Update thread related tests to 3.14.5 (#8018) 2026-06-03 09:52:32 +00:00
Shahar Naveh 42256aab5f Update turtle.py to 3.14.5 (#8017) 2026-06-03 18:36:37 +09:00
Shahar Naveh 840f8c0322 Update asyncio to 3.14.5 (#8012) 2026-06-02 09:48:45 +00:00