mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Raise error on out-of-range input in chr()
This commit is contained in:
1 parent
6228a207e1
commit
ea535856b4
1 file changed
+3
-3
+3
-3
@@ -73,10 +73,10 @@ fn builtin_callable(obj: PyObjectRef, vm: &VirtualMachine) -> bool {
|
||||
vm.is_callable(&obj)
|
||||
}
|
||||
|
||||
fn builtin_chr(i: u32, _vm: &VirtualMachine) -> String {
|
||||
fn builtin_chr(i: u32, vm: &VirtualMachine) -> PyResult<String> {
|
||||
match char::from_u32(i) {
|
||||
Some(value) => value.to_string(),
|
||||
None => '_'.to_string(),
|
||||
Some(value) => Ok(value.to_string()),
|
||||
None => Err(vm.new_value_error("chr() arg not in range(0x110000)".to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user