Commit Graph
19 Commits
Author SHA1 Message Date
Luan Taraschi 8d0e232111 Fix re.findall reporting a group that did not match (#8563)
findall returns the matched text rather than a match object, so a group that
took no part in the match is reported as an empty value. With one group it
was reported as `None`:

    >>> re.findall(r"(a)?b", "b ab")
    [None, 'a']          # CPython: ['', 'a']

The branch for two or more groups was already right, since it passes `""` to
`Match.groups` as the default, so the two halves of the same function
disagreed with each other.

That default is built as a `str` whatever the pattern is, so a `bytes`
pattern came back with `str` mixed into it:

    >>> re.findall(rb"(a)|(b)", b"ab")
    [(b'a', ''), ('', b'b')]     # CPython: [(b'a', b''), (b'', b'b')]

The empty value is now built once from `isbytes` and both branches use it.
`Match.groups` still reports `None`, which is what CPython does.

Assisted-by: Claude Code:claude-opus-5
2026-08-21 17:13:29 +09:00
Joshua Megnauth 6ae61bd4f2 fix: Python-Rust combining char diff in isalnum (#7612)
* fix: Python-Rust combining char diff in isalnum

Related to: #7518

Rust and Python differ on alphanumeric characters. Rust follows the
Unicode standard closer than Python. This means that is_alphanumeric
(char function in Rust) is different from isalnum (Python). To fix the
discrepancy, RustPython needs to mimic Python by rejecting certain
characters. Some classes of combining characters count as alphanumeric
in Rust but not Python. Combining characters are accent marks
that are combined with other characters to create a single grapheme.

It's possible that this PR is not exhaustive. I fixed the combining
character issue BUT I don't know the full range of discrepancies.

* fix: Ignore combining characters in SRE

Closes: #7518
2026-04-17 18:45:43 +09:00
wvmscs c7e94dd1a8 Fix re.fullmatch POSSESSIVE_REPEAT (#7187) 2026-02-20 09:51:34 +09:00
Rex Ledesma 4e2e0b41c6 chore: add ruff format --check (#5774)
* chore: add `ruff format --check`

* fix tests
2025-05-12 14:20:01 +09:00
Kangzhi Shi d7842d1e8e pass htmlparser tests 2022-07-25 22:07:26 +02:00
Kangzhi Shi 5794c46adf fix multiple bugs; pass tests 2021-01-22 16:40:33 +02:00
Kangzhi Shi 5232a3db3e fix back_peek_char 2021-01-21 19:24:10 +02:00
Kangzhi Shi df42fd913f fix at_beginning 2021-01-21 16:14:23 +02:00
Kangzhi Shi 81d791b04b fix op branch 2021-01-21 12:48:32 +02:00
Kangzhi Shi ef7c296001 impl Match.groupdict 2021-01-20 08:29:57 +02:00
Kangzhi Shi de7f07b354 impl Pattern.sub 2021-01-20 08:29:57 +02:00
Kangzhi Shi 3b549cb83e impl Match.__getitem__ 2021-01-20 08:29:57 +02:00
Kangzhi Shi d812a94c68 fix Opcode::BIGCHARSET 2021-01-20 08:29:57 +02:00
Kangzhi Shi 994ab4efb3 fix Opcode::CHARSET 2021-01-20 08:29:57 +02:00
Kangzhi Shi 080b417f1f impl Match.groups() 2021-01-20 08:29:57 +02:00
Kangzhi Shi 884f16cad0 rework OpMaxUntil; restruct popping context; add tests; 2021-01-20 08:29:57 +02:00
Kangzhi Shi f021e6ad65 impl Match.group 2021-01-20 08:29:57 +02:00
Kangzhi Shi 963af86935 impl re.Match object 2021-01-20 08:29:57 +02:00
Jeong YunWon e62a164f4d Move tests -> extra_tests 2020-09-13 06:58:57 +09:00