Skip to content

Commit 804def1

Browse files
author
Michael Recachinas
committed
Replace context.new_property with context.new_str for bool.__doc__
1 parent e557ff2 commit 804def1

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

vm/src/obj/objbool.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ pub fn boolval(vm: &mut VirtualMachine, obj: PyObjectRef) -> Result<bool, PyObje
3131

3232
pub fn init(context: &PyContext) {
3333
let ref bool_type = context.bool_type;
34+
let bool_doc = "bool(x) -> bool
35+
36+
Returns True when the argument x is true, False otherwise.
37+
The builtins True and False are the only two instances of the class bool.
38+
The class bool is a subclass of the class int, and cannot be subclassed.";
39+
3440
context.set_attr(&bool_type, "__new__", context.new_rustfunc(bool_new));
3541
context.set_attr(&bool_type, "__repr__", context.new_rustfunc(bool_repr));
36-
context.set_attr(&bool_type, "__doc__", context.new_property(bool_doc));
42+
context.set_attr(&bool_type, "__doc__", context.new_str(bool_doc.to_string()));
3743
}
3844

3945
pub fn not(vm: &mut VirtualMachine, obj: &PyObjectRef) -> PyResult {
@@ -80,13 +86,3 @@ fn bool_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8086
None => vm.context().new_bool(false),
8187
})
8288
}
83-
84-
fn bool_doc(vm: &mut VirtualMachine, args: PyFuncArgs) -> Result<PyObjectRef, PyObjectRef> {
85-
arg_check!(vm, args, required = [(_zelf, None)]);
86-
let s = "bool(x) -> bool
87-
88-
Returns True when the argument x is true, False otherwise.
89-
The builtins True and False are the only two instances of the class bool.
90-
The class bool is a subclass of the class int, and cannot be subclassed.";
91-
Ok(vm.new_str(s.to_string()))
92-
}

0 commit comments

Comments
 (0)