Commit Graph
22 Commits
Author SHA1 Message Date
Jeong, YunWonandJames David Clarke 1dcdec4dd5 Port the remaining runtime fixes from #7993 (#8995)
* Take re pos/endpos as signed integers

Negative values clamp to 0, and values beyond Py_ssize_t raise
OverflowError.

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

* Port the remaining runtime fixes from #7993

- bytearray: keep the buffer exported while converting the needle of
  find/count/index/rfind/rindex/__contains__/split/rsplit and the hex
  separator, so resizing from there raises BufferError
- str(): report non-str encoding/errors as "str() argument 'X' must be
  str, not T", and check argument counts and name/position duplicates
  for keyword calls
- _json.scanstring: take end as a signed integer and raise ValueError
  when it is out of bounds
- lzma: reject filter specs with keys the filter does not take
- mmap: raise ValueError when growing a shared anonymous mapping on
  Linux/NetBSD
- _sqlite3: check that the backup progress argument is callable
- Remove the expectedFailure markers of the tests these fix

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

* Reject arguments given by name and position in FuncArgs::bind_for

bind_for reports a keyword that fills a parameter already given by
position before other binding errors, using the parameter list of the
FromArgs type. getargs shares the message, str() drops its own check,
and blake2b/blake2s name themselves in binding errors.

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

---------

Co-authored-by: James David Clarke <james@jamesdavidclarke.com>
2026-10-08 08:11:26 +09:00
Jeong, YunWon 6e6792ee5c common: share the hashlib engine, and publish blake2b/blake2s as types (#8643)
The digest, HMAC, PBKDF2 and scrypt state moves out of the `_hashlib`
module into a feature-gated `rustpython_common::hashlib` that owns each
state behind a `Mutex` and reports plain Rust results; `_hashlib` and
`_blake2` keep the object glue.

The engine writes its state through a raw pointer into a caller-owned
buffer, so the buffer is boxed and only the pointer travels with the
Python object, and it carries the alignment the engine asserts.  The
wrapper is built only after a successful init, so a rejected digest name
leaves nothing to drop over storage the engine never wrote.

blake2 moves from `blake2` to `blake2b_simd` / `blake2s_simd`, whose
`Params` carry the whole parameter block.  `_blake2.blake2b` and
`blake2s` become immutable types with `SALT_SIZE`, `PERSON_SIZE`,
`MAX_KEY_SIZE` and `MAX_DIGEST_SIZE` as class attributes, and their
instances are instances of those types.  They accept `key`, `salt`,
`person`, `fanout`, `depth`, `leaf_size`, `node_offset`, `node_depth`,
`inner_size` and `last_node`.  `_hashlib.scrypt` is published on the
same engine.

Six `test_hashlib` expectedFailure markers drop with it.  `blake2`,
`digest`, `dyn-clone`, `hmac` and `pbkdf2` lose their last consumer.

Assisted-by: Grok
Assisted-by: Claude
2026-09-03 22:50:41 +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
Lee Dogeon 77583c7e7e Include SHAKE algorithm names in HASHXOF repr (#7132) 2026-02-15 09:05:42 +09:00
CPython Developers 7b357e42dd Update hashlib from v3.14.3 2026-02-14 21:40:04 +09:00
Lee Dogeon ce60c16b77 Add SHA3 private attribute parity to hashlib hash objects (#7134) 2026-02-14 21:36:57 +09:00
Lee Dogeon 51bdb0617c Make HASH/HASHXOF types immutable (#7131) 2026-02-14 20:37:47 +09:00
Lee Dogeon 3f49f4107c Fix SHAKE digest length overflow in hashlib (#7125) 2026-02-14 19:57:27 +09:00
ShaharNaveh 6cb00e2ae9 Mark failing tests 2025-08-24 00:44:32 +03:00
Jeong, YunWon 6a992d4fa2 Add hashlib hasher repr (#5833) 2025-06-24 20:09:24 +09:00
Jeong YunWon 8c7b811135 Fix _sha512 support 2024-04-11 21:17:53 +09:00
Reid00andzhangbl 9417eec81e feat: update test_hashlib fro CPython3.11 (#5053)
Co-authored-by: zhangbl <zhangbl@greatld.com>
2023-08-30 00:09:21 +09:00
Andrey Maltsev 514014f4fc add compare digest 2023-04-23 21:50:15 +09:00
Andrey Maltsev 508cf6b61d refactoring hashlib for tests 2023-04-23 21:48:02 +09:00
Andrey Maltsev 8782bf8cb0 Update test_hashlib.py from Cpython v3.11.2 2023-04-23 21:45:03 +09:00
Charles Hubain 29de419c87 Implementing shake_128 and shake_256 in the hashlib module. 2023-03-06 00:43:06 +09:00
Charles Hubain b5f54f1624 Integrated hmac.py and test_hmac.py:
* fix typing issue on digest update function
* implemented copy for PyHasher object
* fixed two test_hashlib.py expected failure as a side-effect
2023-02-21 11:35:09 +09:00
Jeong YunWon 38ef6f32ed mark failing tests from test_hashlib 2022-08-15 05:25:42 +09:00
CPython Developers e193f45561 Update hashlib from CPython 3.10.6 2022-08-15 05:25:42 +09:00
Padraic Fanning c8748bc98e Fix test.support imports 2022-02-13 17:56:08 -05:00
Dean Li 6f98288e84 test: use import_helper 2021-11-29 21:03:02 +08:00
Narawit Rakket 45c22af5c7 feat(hashlib): add test_hashlib from CPython v3.9.9 2021-11-29 16:50:24 +07:00