Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/sre_engine/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ pub(crate) const fn is_uni_linebreak(ch: u32) -> bool {

#[inline]
pub(crate) fn is_uni_alnum(ch: u32) -> bool {
// TODO: check with cpython
char::try_from(ch).is_ok_and(rustpython_unicode::classify::is_alnum)
}

Expand Down
9 changes: 9 additions & 0 deletions extra_tests/snippets/builtin_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ class MyString(str):
assert id(b) != id(b * 2)


# Regression tests for isalpha/isalnum Unicode General Category correctness.
# These characters are in letter categories (Ll/Lo) and should return True,
# but were missed in older Unicode tables used by unic-ucd-category.
# See: https://github.com/RustPython/RustPython/pull/7520#issuecomment-4148322294
for _cp in [1376, 1416, 1519, 2160, 2161, 2162, 2163, 2164, 2165, 2166]:
_c = chr(_cp)
assert _c.isalpha(), f"U+{_cp:04X} should be isalpha"
assert _c.isalnum(), f"U+{_cp:04X} should be isalnum"

def test_huge_width():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[reviewdog-suggester] reported by reviewdog 🐶

Suggested change
def test_huge_width():
def test_huge_width():

# A width that cannot be allocated is a MemoryError, not an aborted
# process, and a tabsize wider than a C int does not fit at all.
Expand Down
8 changes: 8 additions & 0 deletions extra_tests/snippets/builtin_str_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

assert c == "👋👋👋"

import re
import unicodedata

assert unicodedata.category("a") == "Ll"
Expand Down Expand Up @@ -44,3 +45,10 @@

assert unicodedata.ucd_3_2_0.east_asian_width("\u231a") == "N"
assert not unicodedata.ucd_3_2_0.mirrored("\u0f3a")

# U+0345 COMBINING GREEK YPOGEGRAMMENI (category Mn) should not be alphanumeric.
# CPython's isalpha/isalnum use Unicode letter categories (Lu/Ll/Lt/Lm/Lo),
# not the broader Unicode Alphabetic derived property.
assert not "\u0345".isalpha(), "isalpha should not match Mn category characters"
assert not "\u0345".isalnum(), "isalnum should not match Mn category characters"
assert not re.match(r"\w", "\u0345"), r"\w should not match U+0345 (category Mn)"
Loading