Skip to content

Commit a089c9b

Browse files
committed
TypeProcotol::lease_class() -> TypeProtocol::class()
1 parent 0a8f1e1 commit a089c9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+145
-178
lines changed

vm/src/anystr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ where
231231
func_name,
232232
py_type_name,
233233
py_type_name,
234-
o.lease_class(),
234+
o.class(),
235235
)
236236
},
237237
vm,

vm/src/builtins.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod decl {
4747
#[pyfunction]
4848
fn abs(x: PyObjectRef, vm: &VirtualMachine) -> PyResult {
4949
let method = vm.get_method_or_type_error(x.clone(), "__abs__", || {
50-
format!("bad operand type for abs(): '{}'", x.lease_class().name)
50+
format!("bad operand type for abs(): '{}'", x.class().name)
5151
})?;
5252
vm.invoke(&method, PyFuncArgs::new(vec![], vec![]))
5353
}
@@ -284,7 +284,7 @@ mod decl {
284284
.map_err(|obj| {
285285
vm.new_type_error(format!(
286286
"__format__ must return a str, not {}",
287-
obj.lease_class().name
287+
obj.class().name
288288
))
289289
})
290290
}
@@ -404,7 +404,7 @@ mod decl {
404404
&|o| {
405405
format!(
406406
"isinstance() arg 2 must be a type or tuple of types, not {}",
407-
o.lease_class()
407+
o.class()
408408
)
409409
},
410410
vm,
@@ -419,7 +419,7 @@ mod decl {
419419
&|o| {
420420
format!(
421421
"issubclass() arg 2 must be a class or tuple of classes, not {}",
422-
o.lease_class()
422+
o.class()
423423
)
424424
},
425425
vm,
@@ -447,7 +447,7 @@ mod decl {
447447
vm._len(&obj).unwrap_or_else(|| {
448448
Err(vm.new_type_error(format!(
449449
"object of type '{}' has no len()",
450-
obj.lease_class().name
450+
obj.class().name
451451
)))
452452
})
453453
}
@@ -826,7 +826,7 @@ mod decl {
826826
};
827827

828828
for base in bases.clone() {
829-
let base_class = base.lease_class();
829+
let base_class = base.class();
830830
if objtype::issubclass(&base_class, &metaclass) {
831831
metaclass = base.clone_class();
832832
} else if !objtype::issubclass(&metaclass, &base_class) {

vm/src/bytesinner.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl TryFromObject for PyBytesInner {
5151
let iter = vm.get_method_or_type_error(obj.clone(), "__iter__", || {
5252
format!(
5353
"a bytes-like object is required, not '{}'",
54-
obj.lease_class().name
54+
obj.class().name
5555
)
5656
})?;
5757
let iter = PyIterable::from_method(iter);
@@ -139,7 +139,7 @@ impl ByteInnerNewOptions {
139139
// .map_err(|_| {
140140
// vm.new_type_error(format!(
141141
// "cannot convert '{}' object to bytes",
142-
// obj.lease_class().name
142+
// obj.class().name
143143
// ))
144144
// })?;
145145
}
@@ -329,7 +329,7 @@ impl PyBytesInner {
329329
let value = vm.to_index(&object).ok_or_else(|| {
330330
vm.new_type_error(format!(
331331
"'{}' object cannot be interpreted as an integer",
332-
object.lease_class().name
332+
object.class().name
333333
))
334334
})?;
335335
// __index__ returned non-int type
@@ -1231,7 +1231,7 @@ pub fn bytes_decode(
12311231
"'{}' decoder returned '{}' instead of 'str'; use codecs.encode() to \
12321232
encode arbitrary types",
12331233
encoding.as_ref().map_or("utf-8", |s| s.borrow_value()),
1234-
obj.lease_class().name,
1234+
obj.class().name,
12351235
))
12361236
})
12371237
}

vm/src/cformat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl CFormatSpec {
311311
"%{} format: {} is required, not {}",
312312
self.format_char,
313313
required_type_string,
314-
obj.lease_class()
314+
obj.class()
315315
))
316316
};
317317
match_class!(match &obj {
@@ -334,7 +334,7 @@ impl CFormatSpec {
334334
vm.new_type_error(format!(
335335
"%{} format: an floating point or integer is required, not {}",
336336
self.format_char,
337-
obj.lease_class().name
337+
obj.class().name
338338
))
339339
})?;
340340
self.format_float(value)

vm/src/exceptions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl PyBaseException {
143143
#[pymethod(name = "__repr__")]
144144
fn repr(zelf: PyRef<Self>, vm: &VirtualMachine) -> String {
145145
let repr_args = exception_args_as_string(vm, zelf.args(), false);
146-
let cls = zelf.lease_class();
146+
let cls = zelf.class();
147147
format!("{}({})", cls.name, repr_args.iter().format(", "))
148148
}
149149
}
@@ -252,7 +252,7 @@ pub fn write_exception_inner<W: Write>(
252252
let varargs = exc.args();
253253
let args_repr = exception_args_as_string(vm, varargs, true);
254254

255-
let exc_name = exc.lease_class().name.clone();
255+
let exc_name = exc.class().name.clone();
256256
match args_repr.len() {
257257
0 => writeln!(output, "{}", exc_name),
258258
1 => writeln!(output, "{}: {}", exc_name, args_repr[0]),
@@ -313,7 +313,7 @@ impl TryFromObject for ExceptionCtor {
313313
.map_err(|obj| {
314314
vm.new_type_error(format!(
315315
"exceptions must be classes or instances deriving from BaseException, not {}",
316-
obj.lease_class().name
316+
obj.class().name
317317
))
318318
})
319319
}
@@ -740,7 +740,7 @@ impl serde::Serialize for SerializeException<'_> {
740740
use serde::ser::*;
741741

742742
let mut struc = s.serialize_struct("PyBaseException", 7)?;
743-
struc.serialize_field("exc_type", &self.exc.lease_class().name)?;
743+
struc.serialize_field("exc_type", &self.exc.class().name)?;
744744
let tbs = {
745745
struct Tracebacks(PyTracebackRef);
746746
impl serde::Serialize for Tracebacks {

vm/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ fn call_object_format(
906906
if !objtype::isinstance(&result, &vm.ctx.types.str_type) {
907907
return Err(vm.new_type_error(format!(
908908
"__format__ must return a str, not {}",
909-
&result.lease_class().name
909+
&result.class().name
910910
)));
911911
}
912912
Ok(result)

vm/src/frame.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl ExecutingFrame<'_> {
593593
vm.get_method_or_type_error(awaited_obj.clone(), "__await__", || {
594594
format!(
595595
"object {} can't be used in 'await' expression",
596-
awaited_obj.lease_class().name,
596+
awaited_obj.class().name,
597597
)
598598
})?;
599599
vm.invoke(&await_method, vec![])?
@@ -686,10 +686,10 @@ impl ExecutingFrame<'_> {
686686
bytecode::Instruction::UnpackSequence { size } => {
687687
let value = self.pop_value();
688688
let elements = vm.extract_elements(&value).map_err(|e| {
689-
if e.lease_class().is(&vm.ctx.exceptions.type_error) {
689+
if e.class().is(&vm.ctx.exceptions.type_error) {
690690
vm.new_type_error(format!(
691691
"cannot unpack non-iterable {} object",
692-
value.lease_class().name
692+
value.class().name
693693
))
694694
} else {
695695
e
@@ -996,10 +996,7 @@ impl ExecutingFrame<'_> {
996996
for obj in self.pop_multiple(size) {
997997
// Take all key-value pairs from the dict:
998998
let dict: PyDictRef = obj.downcast().map_err(|obj| {
999-
vm.new_type_error(format!(
1000-
"'{}' object is not a mapping",
1001-
obj.lease_class().name
1002-
))
999+
vm.new_type_error(format!("'{}' object is not a mapping", obj.class().name))
10031000
})?;
10041001
for (key, value) in dict {
10051002
if for_call {

vm/src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl PyFuncArgs {
130130
Ok(Some(kwarg))
131131
} else {
132132
let expected_ty_name = &ty.name;
133-
let actual_ty_name = &kwarg.lease_class().name;
133+
let actual_ty_name = &kwarg.class().name;
134134
Err(vm.new_type_error(format!(
135135
"argument of type {} is required for named parameter `{}` (got: {})",
136136
expected_ty_name, key, actual_ty_name

vm/src/obj/objbool.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ impl TryFromObject for bool {
2323
if objtype::isinstance(&obj, &vm.ctx.types.int_type) {
2424
Ok(get_value(&obj))
2525
} else {
26-
Err(vm.new_type_error(format!(
27-
"Expected type bool, not {}",
28-
obj.lease_class().name
29-
)))
26+
Err(vm.new_type_error(format!("Expected type bool, not {}", obj.class().name)))
3027
}
3128
}
3229
}
@@ -47,7 +44,7 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool> {
4744
if !objtype::isinstance(&bool_obj, &vm.ctx.types.bool_type) {
4845
return Err(vm.new_type_error(format!(
4946
"__bool__ should return bool, returned type {}",
50-
bool_obj.lease_class().name
47+
bool_obj.class().name
5148
)));
5249
}
5350

@@ -60,7 +57,7 @@ pub fn boolval(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<bool> {
6057
let int_obj = bool_obj.payload::<PyInt>().ok_or_else(|| {
6158
vm.new_type_error(format!(
6259
"'{}' object cannot be interpreted as an integer",
63-
bool_obj.lease_class().name
60+
bool_obj.class().name
6461
))
6562
})?;
6663

@@ -145,7 +142,7 @@ impl PyBool {
145142
#[pyslot]
146143
fn tp_new(zelf: PyObjectRef, x: OptionalArg<PyObjectRef>, vm: &VirtualMachine) -> PyResult {
147144
if !objtype::isinstance(&zelf, &vm.ctx.types.type_type) {
148-
let actual_type = &zelf.lease_class().name;
145+
let actual_type = &zelf.class().name;
149146
return Err(vm.new_type_error(format!(
150147
"requires a 'type' object but received a '{}'",
151148
actual_type

vm/src/obj/objbuiltinfunc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl SlotDescriptor for PyBuiltinMethod {
183183
Ok(obj) => obj,
184184
Err(result) => return result,
185185
};
186-
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.lease_class()) {
186+
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.class()) {
187187
Ok(zelf.into_object())
188188
} else {
189189
Ok(vm.ctx.new_bound_method(zelf.into_object(), obj))

vm/src/obj/objcomplex.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl PyComplex {
242242
} else {
243243
return Err(vm.new_type_error(format!(
244244
"complex() first argument must be a string or a number, not '{}'",
245-
obj.lease_class().name
245+
obj.class().name
246246
)));
247247
}
248248
}
@@ -253,14 +253,14 @@ impl PyComplex {
253253
Some(obj) => {
254254
if let Some(c) = try_complex(&obj, vm)? {
255255
c
256-
} else if objtype::issubclass(obj.lease_class(), &vm.ctx.types.str_type) {
256+
} else if objtype::issubclass(obj.class(), &vm.ctx.types.str_type) {
257257
return Err(
258258
vm.new_type_error("complex() second arg can't be a string".to_owned())
259259
);
260260
} else {
261261
return Err(vm.new_type_error(format!(
262262
"complex() second argument must be a number, not '{}'",
263-
obj.lease_class().name
263+
obj.class().name
264264
)));
265265
}
266266
}

vm/src/obj/objdict.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl PyDictRef {
464464
// and prevent the creation of the KeyError exception.
465465
// Also note, that we prevent the creation of a full PyStr object
466466
// if we lookup local names (which happens all of the time).
467-
if self.lease_class().is(&vm.ctx.types.dict_type) {
467+
if self.class().is(&vm.ctx.types.dict_type) {
468468
// We can take the short path here!
469469
match self.inner_getitem_option(key, vm) {
470470
Err(exc) => {
@@ -502,7 +502,7 @@ where
502502
}
503503

504504
fn set_item(&self, key: K, value: PyObjectRef, vm: &VirtualMachine) -> PyResult {
505-
if self.lease_class().is(&vm.ctx.types.dict_type) {
505+
if self.class().is(&vm.ctx.types.dict_type) {
506506
self.inner_setitem_fast(key, value, vm)
507507
.map(|_| vm.ctx.none())
508508
} else {
@@ -512,7 +512,7 @@ where
512512
}
513513

514514
fn del_item(&self, key: K, vm: &VirtualMachine) -> PyResult {
515-
if self.lease_class().is(&vm.ctx.types.dict_type) {
515+
if self.class().is(&vm.ctx.types.dict_type) {
516516
self.entries.delete(vm, key).map(|_| vm.ctx.none())
517517
} else {
518518
// Fall back to slow path if we are in a dict subclass:
@@ -628,7 +628,7 @@ macro_rules! dict_iterator {
628628
&zelf.dict,
629629
&dictview.dict,
630630
op,
631-
!zelf.lease_class().is(&vm.ctx.types.dict_keys_type),
631+
!zelf.class().is(&vm.ctx.types.dict_keys_type),
632632
vm,
633633
)
634634
}

vm/src/obj/objfloat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ fn to_float(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<f64> {
511511
let method = vm.get_method_or_type_error(obj.clone(), "__float__", || {
512512
format!(
513513
"float() argument must be a string or a number, not '{}'",
514-
obj.lease_class().name
514+
obj.class().name
515515
)
516516
})?;
517517
let result = vm.invoke(&method, vec![])?;

vm/src/obj/objfunction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl SlotDescriptor for PyFunction {
312312
vm: &VirtualMachine,
313313
) -> PyResult {
314314
let (zelf, obj) = Self::_unwrap(zelf, obj, vm)?;
315-
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.lease_class()) {
315+
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.class()) {
316316
Ok(zelf.into_object())
317317
} else {
318318
Ok(vm.ctx.new_bound_method(zelf.into_object(), obj))

vm/src/obj/objfunction/jitfunc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn get_jit_arg_types(func: &PyFunctionRef, vm: &VirtualMachine) -> PyResult<
105105

106106
fn get_jit_value(vm: &VirtualMachine, obj: &PyObjectRef) -> Result<AbiValue, ArgsError> {
107107
// This does exact type checks as subclasses of int/float can't be passed to jitted functions
108-
let cls = obj.lease_class();
108+
let cls = obj.class();
109109
if cls.is(&vm.ctx.types.int_type) {
110110
objint::get_value(&obj)
111111
.to_i64()

vm/src/obj/objgetset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl PyGetSet {
240240
Err(vm.new_attribute_error(format!(
241241
"attribute '{}' of '{}' objects is not writable",
242242
self.name,
243-
obj.lease_class().name
243+
obj.class().name
244244
)))
245245
}
246246
}

vm/src/obj/objint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl PyInt {
257257
.unwrap_or_else(|| {
258258
Err(vm.new_type_error(format!(
259259
"'{}' object cannot be interpreted as an integer",
260-
base.lease_class().name
260+
base.class().name
261261
)))
262262
})?
263263
.borrow_value()
@@ -456,13 +456,13 @@ impl PyInt {
456456
let _ndigits = value.payload_if_subclass::<PyInt>(vm).ok_or_else(|| {
457457
vm.new_type_error(format!(
458458
"'{}' object cannot be interpreted as an integer",
459-
value.lease_class().name
459+
value.class().name
460460
))
461461
})?;
462462
} else {
463463
return Err(vm.new_type_error(format!(
464464
"'{}' object cannot be interpreted as an integer",
465-
value.lease_class().name
465+
value.class().name
466466
)));
467467
}
468468
}
@@ -737,7 +737,7 @@ pub(crate) fn to_int(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<BigInt>
737737
Some(int_obj) => Ok(int_obj.borrow_value().clone()),
738738
None => Err(vm.new_type_error(format!(
739739
"__int__ returned non-int (type '{}')",
740-
result.lease_class().name
740+
result.class().name
741741
))),
742742
};
743743
}
@@ -748,7 +748,7 @@ pub(crate) fn to_int(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<BigInt>
748748

749749
Err(vm.new_type_error(format!(
750750
"int() argument must be a string, a bytes-like object or a number, not '{}'",
751-
obj.lease_class().name
751+
obj.class().name
752752
)))
753753
}
754754

0 commit comments

Comments
 (0)