Skip to content

Commit 1c92f5d

Browse files
authored
Merge pull request RustPython#2275 from youknowone/lease-class
more lease_class
2 parents 1c3d7ae + 6e60915 commit 1c92f5d

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

vm/src/bytesinner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl ByteInnerNewOptions {
139139
// .map_err(|_| {
140140
// vm.new_type_error(format!(
141141
// "cannot convert '{}' object to bytes",
142-
// obj.class().name
142+
// obj.lease_class().name
143143
// ))
144144
// })?;
145145
}

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.class()) {
186+
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.lease_class()) {
187187
Ok(zelf.into_object())
188188
} else {
189189
Ok(vm.ctx.new_bound_method(zelf.into_object(), obj))

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.class()) {
315+
if vm.is_none(&obj) && !Self::_cls_is(&cls, &obj.lease_class()) {
316316
Ok(zelf.into_object())
317317
} else {
318318
Ok(vm.ctx.new_bound_method(zelf.into_object(), obj))

vm/src/obj/objint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.class().name
740+
result.lease_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.class().name
751+
obj.lease_class().name
752752
)))
753753
}
754754

vm/src/obj/objmemory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@ impl Comparable for PyMemoryView {
752752
_ => Err(vm.new_type_error(format!(
753753
"'{}' not supported between instances of '{}' and '{}'",
754754
op.operator_token(),
755-
zelf.class().name,
756-
other.class().name
755+
zelf.lease_class().name,
756+
other.lease_class().name
757757
))),
758758
}
759759
}
@@ -776,7 +776,7 @@ pub(crate) fn init(ctx: &PyContext) {
776776
}
777777

778778
pub fn try_buffer_from_object(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<BufferRef> {
779-
let obj_cls = obj.class();
779+
let obj_cls = obj.lease_class();
780780
for cls in obj_cls.iter_mro() {
781781
if let Some(f) = cls.slots.buffer.as_ref() {
782782
return f(obj, vm).map(|x| BufferRef(x));

vm/src/obj/objobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl PyBaseObject {
185185

186186
#[pymethod(magic)]
187187
pub fn dir(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyList> {
188-
let attributes: PyAttributes = obj.class().get_attributes();
188+
let attributes: PyAttributes = obj.lease_class().get_attributes();
189189

190190
let dict = PyDict::from_attributes(attributes, vm)?.into_ref(vm);
191191

vm/src/obj/objtuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl PyTuple {
7777
let py_int = PyIntRef::try_from_object(vm, elem.clone()).map_err(|_| {
7878
vm.new_type_error(format!(
7979
"'{}' object cannot be interpreted as an integer",
80-
elem.class().name
80+
elem.lease_class().name
8181
))
8282
})?;
8383
let result = py_int

vm/src/slots.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub trait SlotDescriptor: PyValue {
183183
where
184184
T: IdProtocol,
185185
{
186-
cls.as_ref().map_or(false, |cls| cls.is(other))
186+
cls.as_ref().map_or(false, |cls| other.is(cls))
187187
}
188188
}
189189

vm/src/stdlib/math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn math_isqrt(x: PyObjectRef, vm: &VirtualMachine) -> PyResult<BigInt> {
139139
let index = vm.to_index(&x).ok_or_else(|| {
140140
vm.new_type_error(format!(
141141
"'{}' object cannot be interpreted as an integer",
142-
x.class().name
142+
x.lease_class().name
143143
))
144144
})?;
145145
// __index__ may have returned non-int type

0 commit comments

Comments
 (0)