Commit Graph
1534 Commits
Author SHA1 Message Date
Shahar Naveh 619f423084 Replace &String -> &str (#8136) 2026-06-22 16:42:54 +09:00
Bas Schoenmaeckers 2ce6fd0e41 Add stdlib to c-api (#8133) 2026-06-22 16:38:33 +09:00
Shahar Naveh 9f2c4e14a9 More clippy rules (#8127)
* clippy `elidable_lifetime_names`

* large_types_passed_by_value

* trivially_copy_pass_by_ref

* type_repetition_in_bounds

* copy_iterator

* collection_is_never_read

* same_functions_in_if_condition

* unnecessary_struct_initialization

* clippy on windows

* ssl windows
2026-06-22 16:30:51 +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
Kwak Byoung MinandShahar Naveh 6d25033da6 Support csv writer QUOTE_STRINGS and QUOTE_NOTNULL (#8109)
* Support csv quoting modes added in Python 3.12

Implement writer handling for QUOTE_STRINGS and QUOTE_NOTNULL so the exported constants no longer panic and follow CPython behavior for string, non-null, None, and quotechar validation cases.

Constraint: RustPython contribution policy requires CPython-compatible behavior through Rust-side changes and regression coverage outside Lib/.

Rejected: Marking CPython Lib tests or hiding the constants | would preserve a runtime panic for supported public constants.

Confidence: high

Scope-risk: narrow

Directive: Keep QUOTE_STRINGS and QUOTE_NOTNULL writer behavior aligned with CPython's csv module when extending dialect validation.

Tested: cargo check -p rustpython-stdlib; cargo run --release -- extra_tests/snippets/stdlib_csv.py; cargo run --release -- -m test test_csv; cargo clippy; pre-commit run --all-files via temporary venv/PATH shim; cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher -- --test-threads=1

Not-tested: Remote CI and PR creation were not run because remote git operations require explicit approval.

Assisted-by: Codex:gpt-5.5

* Update crates/stdlib/src/csv.rs

Co-authored-by: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com>

* Update crates/stdlib/src/csv.rs

Co-authored-by: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com>

* Keep csv writer follow-up lint clean

Apply maintainer-requested expression cleanups and rustfmt wrapping so the PR lint job can pass without changing behavior.

Constraint: GitHub Actions Lint failed on rustfmt output after the review suggestion.

Rejected: Changing csv writer semantics | the failing check was formatting-only and all behavior tests already passed.

Confidence: high

Scope-risk: narrow

Directive: Keep future review suggestions rustfmt-clean before pushing.

Tested: cargo fmt --check; cargo check -p rustpython-stdlib; cargo run --release -- extra_tests/snippets/stdlib_csv.py; cargo run --release -- -m test test_csv; cargo clippy; pre-commit run --all-files; cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher -- --test-threads=1

Not-tested: Remote CI has not rerun yet; this commit will trigger it after push.

Assisted-by: Codex:gpt-5.5

---------

Co-authored-by: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com>
2026-06-22 13:17:55 +09:00
Shahar Naveh a1b54bc4e7 General code nits (#8107)
* General nits

* compiler

* cformat

* gc_state

* fix release compile

* Fix logic error

* revert bad logic error

* don't inline elapsed_time
2026-06-22 13:17:21 +09:00
Shahar Naveh 63b99b8996 More clippy rules (#8123)
* clippy `bool_to_int_with_if`

* doc_link_with_quotes

* ip_constant

* single_char_pattern

* windows
2026-06-17 13:25:38 +09:00
Shahar Naveh 455e2624ad Clippy ref_option (#8122) 2026-06-17 13:24:59 +09:00
Shahar Naveh 11da0b42c3 clippy enum_glob_use (#8121) 2026-06-17 13:24:36 +09:00
Joshua Megnauth 697a441e70 host_env: renameat support for os.rename (#8118)
Python's `os.rename` supports renaming a path relative to a directory
descriptor - essentially, `renameat`. The syscall and its Rustix wrapper
does all of the work, so this patch mainly updates the Python signature
to forward to the implementation.

As of this patch, `os.rename` is still incorrect for Windows because it
always replaces the destination file. I added a small note for future
contributors (or myself, since I might tackle it) as a reminder of
what's broken.
2026-06-17 13:24:01 +09:00
Shahar Naveh 40197480e9 Use KwArgs newtype struct (#8120) 2026-06-16 22:38:01 +09:00
Shahar Naveh 5893c688c9 Fix builtin class names not being interned (#8116) 2026-06-16 17:15:01 +09:00
github-actions[bot]andgithub-actions[bot] cbfa330780 Update doc DB for CPython 3.14.6 (#8106)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-16 15:59:36 +09:00
Shahar Naveh 72052484ca clippy significant_drop_in_scrutinee & explicit_deref_methods (#8104) 2026-06-15 11:21:13 +09:00
Shahar Naveh 7da696661b Reduce number of string clones when compiling python source code (#8103) 2026-06-15 11:20:48 +09:00
Joshua Megnauth 271d3c2af1 host_env: Use Rustix for copy_file_range (#8099)
Rustix bypasses `libc` to make direct syscalls on Linux. Rustix is also
semantically cleaner than `libc` itself. For `copy_file_range`, the
offsets can't be negative but `libc`'s `off_t` type is an `i64` because
it's used elsewhere, including for functions that CAN take a negative
offset. Rustix is cleaner because the offsets are `u64`.
2026-06-15 11:18:31 +09:00
Shahar Naveh d758d60eb1 Newtype SigalNum (#8096)
* Newtype SigalNum

* impl Index<SigalNum> for SignalHandlersInner
2026-06-15 11:12:39 +09:00
Shahar Naveh c3e1f0fa37 Get all builtin types dynamiclly (#8095) 2026-06-15 11:11:32 +09:00
Joshua Megnauth 5c1803e019 Fix most of unicodedata; unmask multiple tests (#7947) 2026-06-14 17:47:42 +09:00
Shahar Naveh a895eeed00 Newtype SignalHandlers (#8089) 2026-06-14 13:53:18 +09:00
github-actions[bot]andgithub-actions[bot] f34cfca1f3 Update doc DB for CPython 3.14.6 (#8088)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-12 23:58:41 +09:00
Shahar Naveh 52c2d3fd61 cleanup the signals module (#8076) 2026-06-12 17:20:51 +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 f89f415061 Remove redundant to_owned() calls (#8077) 2026-06-12 11:09:22 +09:00
Kwak Byoung Min 3492c1cef1 Avoid callable iterator deadlock during sentinel comparison (#8040)
Constraint: Python-level sentinel equality can re-enter the same callable iterator while internal iterator state is protected by a non-reentrant lock.

Rejected: Holding the callable iterator status lock across sentinel equality | user-defined __eq__ can call next() on the same iterator and deadlock.

Confidence: high

Scope-risk: moderate

Tested: pre-commit run --all-files; cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher; cargo build --release --features sqlite; pytest -v in extra_tests; cargo run --quiet -- extra_tests/snippets/protocol_iternext.py; cargo check -p rustpython-vm; cargo clippy -p rustpython-vm --all-targets -- -D warnings; git diff --check

Not-tested: push/PR creation

Assisted-by: Codex:gpt-5.5
2026-06-11 13:38:07 +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 6d507c2af1 Add _heapq module (#8059)
* Basic `_heapq` module

* Accept generic siftup functions
2026-06-11 12:11:54 +09:00
Shahar Naveh e6b1fd038b Code nitpicks (#8058)
* Code nitpicks

* fix error message

* Use `vm.new_.*_error` methods
2026-06-11 11:40:11 +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 dc81e050c6 more clippy rules (#8050)
* `checked_conversions`

* duration_suboptimal_units

* inefficient_to_string

* iter_on_single_items

* needless_collect

* needless_for_each

* ptr_offset_by_literal

* return_self_not_must_use
2026-06-10 11:13:42 +09:00
Bas Schoenmaeckers 84ba5c25d7 Add more list functions to the c-api (#8045) 2026-06-10 11:05:18 +09:00
Bas Schoenmaeckers 1782dd25ae Add more unicode functions to c-api (#8044)
* Add more unicode functions to c-api

* Update crates/capi/src/unicodeobject.rs
2026-06-10 11:04:40 +09:00
Bas Schoenmaeckers cff6f9c2a7 Add more dict functions to c-api (#8043) 2026-06-10 11:03:29 +09:00
Bas Schoenmaeckers da8e6eef1f Add more object functions to c-api (#8042) 2026-06-10 11:02:26 +09:00
Shahar Naveh fb9a5ca65b General code nits (#8041) 2026-06-10 11:00:58 +09:00
Shahar Naveh 4143af54f7 Add set_attrs! macro for setting multiple attributes on an object (#8034) 2026-06-09 10:12:57 +09:00
Bas Schoenmaeckers a60fe11883 Add iter support to c-api (#8035) 2026-06-04 10:34:28 +09:00
Bas Schoenmaeckers 1a92b4ae07 Add PyDictProxy_New to the c-api (#8033) 2026-06-03 15:45:26 +00:00
Jeong, YunWon cf4d076ad4 xz (#7756) 2026-06-04 00:18:55 +09:00
Bas Schoenmaeckers 009080dba7 Add basic module functions to c-api (#8032) 2026-06-03 22:52:17 +09:00
Alok Pandey 5f789c6146 Fix WASM memory allocation failure (#4989) (#7887)
* Fix WASM memory allocation failure (#4989)

This commit addresses the unbounded memory allocation issue on WASM targets that caused minimal programs (like  = 1) to fail with ~79MB allocation errors in constrained runtimes like wasmi.

The fixes include:
1. Capping the max memory limit at 64MB and restricting stack size to 1MB via linker flags in .cargo/config.toml.
2. Reducing the minimum chunk size of the DataStack from 16KB to 4KB on WASM targets to shrink the initial memory footprint.
3. Adding a wasm-release profile in the root Cargo.toml optimized for size with opt-level = s, LTO enabled, and symbols stripped.

* Trigger CI rerun

* Address review feedback: add comments, use cfg! for MIN_CHUNK_SIZE

* Remove duplicate MIN_CHUNK_SIZE definition

* Fix duplicate MIN_CHUNK_SIZE and format for prek lint

* Update CI to use wasm-release profile for WASM tests

* Remove leftover conflict markers

* Clean remaining conflict markers in CI workflow

* Clean remaining conflict markers in CI workflow

* Trigger CI to pick up new required check

* Remove --max-memory flag, keep stack limit only
2026-06-03 20:32:24 +09:00
Shahar Naveh fe6b9e8403 Update thread related tests to 3.14.5 (#8018) 2026-06-03 09:52:32 +00:00
Bas Schoenmaeckers 2723ebd81c Add warning functions to c-api (#8020) 2026-06-03 18:39:24 +09:00
Joshua Megnauth 3d53342b61 Update random and cryptography crates (#8010)
Redo of #7800.

Bumping the random and crypto crates is not trivial. Both sets of crates
have had API changes which require manual updates.

AI use:
I wrote all of the code myself but used AI to figure out the new APIs.
AI explained SHAKE's block size and why the block_size() function
doesn't exist in the new crate. I confirmed the block size, which is
actually represented in the new types for SHAKE. `Shake128` is actually
`Shake<168>` - 168 is the block size. I cited Wikipedia as it lists the
SHAKE block size in bits.

I also used AI to figure out HMAC for SHA3.

Assisted-by: Codex:gpt-5.4
2026-06-03 18:38:28 +09:00
Bas Schoenmaeckers f3ee5099ac Add bytesarray support to the c-api (#8009)
* Add bytesarray support to the c-api

* Add SAFETY comment
2026-06-03 18:36:15 +09:00
Bas Schoenmaeckers 6937f3b559 Add slice functions to c-api (#8019) 2026-06-03 18:35:31 +09:00
Bas Schoenmaeckers 7f97f9b2b7 Add number protocol functions (#8005) 2026-06-03 18:34:49 +09:00
Bas Schoenmaeckers c1aeeef7f8 Add sequence protocol to the c-api (#8016) 2026-06-02 09:33:26 +00:00
Bas Schoenmaeckers d411a2b9d0 Add weakref support to c-api (#8006) 2026-06-02 15:31:21 +09:00
Bas Schoenmaeckers 8af0f8ab7b Add mapping c-api functions (#8003) 2026-06-02 15:20:45 +09:00