Skip to content

Commit 1612c95

Browse files
committed
Add weakproxy test
1 parent cc76bf7 commit 1612c95

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tests/snippets/weakrefs.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from _weakref import ref
1+
from _weakref import ref, proxy
2+
from testutils import assert_raises
23

34

45
class X:
@@ -11,3 +12,17 @@ class X:
1112
assert callable(b)
1213
assert b() is a
1314

15+
16+
class G:
17+
def __init__(self, h):
18+
self.h = h
19+
20+
21+
g = G(5)
22+
p = proxy(g)
23+
24+
assert p.h == 5
25+
26+
del g
27+
28+
assert_raises(ReferenceError, lambda: p.h)

vm/src/builtins.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
751751
"NameError" => ctx.exceptions.name_error.clone(),
752752
"OverflowError" => ctx.exceptions.overflow_error.clone(),
753753
"RuntimeError" => ctx.exceptions.runtime_error.clone(),
754+
"ReferenceError" => ctx.exceptions.reference_error.clone(),
754755
"NotImplementedError" => ctx.exceptions.not_implemented_error.clone(),
755756
"TypeError" => ctx.exceptions.type_error.clone(),
756757
"ValueError" => ctx.exceptions.value_error.clone(),

0 commit comments

Comments
 (0)