Skip to content

Commit c01dc53

Browse files
committed
Add callback parameter to weakref, at the moment this callback isn't yet
implement though.
1 parent ea87252 commit c01dc53

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

tests/snippets/test_abc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __subclasshook__(cls, subclass):
1313
return NotImplemented
1414

1515

16+
# TODO raise an error if there are in any abstract methods not fulfilled
1617
# with assertRaises(TypeError):
1718
# CustomInterface()
1819

@@ -31,4 +32,8 @@ class SubConcrete(Concrete):
3132

3233
assert issubclass(Concrete, CustomInterface)
3334
assert issubclass(SubConcrete, CustomInterface)
35+
assert not issubclass(tuple, CustomInterface)
3436

37+
assert isinstance(Concrete(), CustomInterface)
38+
assert isinstance(SubConcrete(), CustomInterface)
39+
assert not isinstance((), CustomInterface)

vm/src/obj/objweakref.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::pyobject::PyValue;
33
use crate::pyobject::{PyContext, PyObject, PyObjectPayload, PyObjectRef, PyRef, PyResult};
44
use crate::vm::VirtualMachine;
55

6+
use crate::function::OptionalArg;
67
use std::rc::{Rc, Weak};
78

89
#[derive(Debug)]
@@ -32,7 +33,12 @@ pub type PyWeakRef = PyRef<PyWeak>;
3233

3334
impl PyWeakRef {
3435
// TODO callbacks
35-
fn create(cls: PyClassRef, referent: PyObjectRef, vm: &VirtualMachine) -> PyResult<Self> {
36+
fn create(
37+
cls: PyClassRef,
38+
referent: PyObjectRef,
39+
_callback: OptionalArg<PyObjectRef>,
40+
vm: &VirtualMachine,
41+
) -> PyResult<Self> {
3642
PyWeak::downgrade(&referent).into_ref_with_type(vm, cls)
3743
}
3844

0 commit comments

Comments
 (0)