File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
from mypyc .ir .ops import ERR_MAGIC
2
2
from mypyc .ir .rtypes import object_rprimitive
3
- from mypyc .primitives .registry import function_op
3
+ from mypyc .primitives .registry import ERR_NEG_INT , function_op
4
4
5
5
# Weakref operations
6
6
11
11
c_function_name = "PyWeakref_NewRef" ,
12
12
error_kind = ERR_MAGIC ,
13
13
)
14
+
15
+ deref_op = function_op (
16
+ name = "weakref.ReferenceType.__call__" ,
17
+ arg_types = [object_rprimitive ],
18
+ return_type = object_rprimitive ,
19
+ c_function_name = "PyWeakref_GetRef" ,
20
+ error_kind = ERR_NEG_INT ,
21
+ )
Original file line number Diff line number Diff line change 15
15
from typing import Any, Callable
16
16
from weakref import ref
17
17
def f(x: object, cb: Callable[[object], Any]) -> object:
18
- return ref(x, cb)
18
+ return ref(x, cb)()
19
19
20
20
[out]
21
21
def f(x, cb):
22
- x, cb, r0 :: object
22
+ x, cb, r0, r1 :: object
23
23
L0:
24
24
r0 = PyWeakref_NewRef(x, cb)
25
- return r0
25
+ r1 = PyWeakref_GetRef(r0)
26
+ return r1
You can’t perform that action at this time.
0 commit comments