-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Python-Rust combining char diff in isalnum #7612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,8 +44,12 @@ use rustpython_common::{ | |||||
| wtf8::{CodePoint, Wtf8, Wtf8Buf, Wtf8Chunk, Wtf8Concat}, | ||||||
| }; | ||||||
|
|
||||||
| use icu_properties::props::{ | ||||||
| BidiClass, BinaryProperty, EnumeratedProperty, GeneralCategory, XidContinue, XidStart, | ||||||
| use icu_properties::{ | ||||||
| CodePointMapData, | ||||||
| props::{ | ||||||
| BidiClass, BinaryProperty, CanonicalCombiningClass, EnumeratedProperty, GeneralCategory, | ||||||
| XidContinue, XidStart, | ||||||
| }, | ||||||
| }; | ||||||
| use unicode_casing::CharExt; | ||||||
|
|
||||||
|
|
@@ -946,7 +950,11 @@ impl PyStr { | |||||
|
|
||||||
| #[pymethod] | ||||||
| fn isalnum(&self) -> bool { | ||||||
| !self.data.is_empty() && self.char_all(char::is_alphanumeric) | ||||||
| let map = CodePointMapData::<CanonicalCombiningClass>::new(); | ||||||
| !self.data.is_empty() | ||||||
| && self.char_all(|c| { | ||||||
| c.is_alphanumeric() && map.get(c) == CanonicalCombiningClass::NotReordered | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove line 953 and
Suggested change
|
||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| #[pymethod] | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,15 @@ | |||||
| assert a.istitle() | ||||||
| assert a.isalpha() | ||||||
|
|
||||||
| # Combining characters differ slightly between Rust and Python | ||||||
| assert "\u006e".isalnum() | ||||||
| assert not "\u0303".isalnum() | ||||||
| assert not "\u006e\u0303".isalnum() | ||||||
| assert "\u00f1".isalnum() | ||||||
| assert not "\u0345".isalnum() | ||||||
| for raw in range(0x0363, 0x036f): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| assert not chr(raw).isalnum() | ||||||
|
|
||||||
| s = "1 2 3" | ||||||
| assert s.split(" ", 1) == ["1", "2 3"] | ||||||
| assert s.rsplit(" ", 1) == ["1 2", "3"] | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line 446 and: