Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into reversed
  • Loading branch information
OddCoincidence committed Feb 9, 2019
commit 969ddf2ea039c046259e46cda06515fa4f04b240
1 change: 1 addition & 0 deletions vm/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
ctx.set_attr(&py_mod, "range", ctx.range_type());
ctx.set_attr(&py_mod, "repr", ctx.new_rustfunc(builtin_repr));
ctx.set_attr(&py_mod, "reversed", ctx.new_rustfunc(builtin_reversed));
ctx.set_attr(&py_mod, "round", ctx.new_rustfunc(builtin_round));
ctx.set_attr(&py_mod, "set", ctx.set_type());
ctx.set_attr(&py_mod, "setattr", ctx.new_rustfunc(builtin_setattr));
ctx.set_attr(&py_mod, "slice", ctx.slice_type());
Expand Down
13 changes: 13 additions & 0 deletions vm/src/obj/objrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ impl RangeType {
Sign::NoSign => unreachable!(),
}
}

pub fn repr(&self) -> String {
if self.step == BigInt::one() {
format!("range({}, {})", self.start, self.end)
} else {
format!("range({}, {}, {})", self.start, self.end, self.step)
}
}
}

pub fn init(context: &PyContext) {
Expand All @@ -129,6 +137,11 @@ pub fn init(context: &PyContext) {
"__reversed__",
context.new_rustfunc(range_reversed),
);
context.set_attr(
&range_type,
"__doc__",
context.new_str(range_doc.to_string()),
);
context.set_attr(&range_type, "__len__", context.new_rustfunc(range_len));
context.set_attr(
&range_type,
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.