Skip to content

Commit cf23884

Browse files
authored
test(str): add regression test for isprintable() unicode 15 chars, (RustPython#7766)
Fixes RustPython#7525
1 parent c3c9292 commit cf23884

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

crates/vm/src/builtins/str.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,4 +2726,24 @@ mod tests {
27262726
assert_eq!("TypeError", &*translated.unwrap_err().class().name(),);
27272727
})
27282728
}
2729+
2730+
#[test]
2731+
fn str_isprintable_unicode15() {
2732+
// Regression test for https://github.com/RustPython/RustPython/issues/7525
2733+
// At the time of the issue, RustPython used unic_ucd_category which had
2734+
// outdated Unicode data, causing U+0B55 to be misclassified as Unassigned.
2735+
// Now fixed by migrating to icu_properties with up-to-date Unicode data.
2736+
2737+
// Characters that should be printable
2738+
assert!(PyStr::from("\u{0B55}").isprintable());
2739+
assert!(PyStr::from("A").isprintable());
2740+
assert!(PyStr::from(" ").isprintable());
2741+
assert!(PyStr::from("").isprintable());
2742+
2743+
// Characters that should NOT be printable
2744+
assert!(!PyStr::from("\x00").isprintable());
2745+
assert!(!PyStr::from("\u{200B}").isprintable());
2746+
assert!(!PyStr::from("\u{E000}").isprintable());
2747+
assert!(!PyStr::from("\u{00A0}").isprintable());
2748+
}
27292749
}

0 commit comments

Comments
 (0)