-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·66 lines (53 loc) · 1.29 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
import libreproducer
# ClassB doesn't work, unless b.a is first assigned to a local and then dereferenced
b = libreproducer.ClassB()
print('case1 B', b.a.x)
b.a.x = 1
print(b.a.x, b.a.x == 1)
a = libreproducer.ClassA()
print('case2 A', a.x)
a.x = 1
print(a.x, a.x == 1)
b = libreproducer.ClassB()
print('case3 B', b.a.x)
a = b.a
a.x = 1
print(b.a.x, b.a.x == 1)
# it's confusing why the above doesn't work
b = libreproducer.ClassB()
print('case4 B', b.a.x)
a = b.a
a.x = 1
b.a = a
del a
print(b.a.x, b.a.x == 1)
# it's confusing why the above works but the below still doesn't work
b.a.x = 2
print(b.a.x, b.a.x == 2)
# ClassB2 below always works but cannot derive Serialized/Deserialize
b = libreproducer.ClassB2()
print('case1 B2', b.a.x)
b.a.x = 1
print(b.a.x, b.a.x == 1)
b = libreproducer.ClassB2()
print('case3 B2', b.a.x)
a = b.a
a.x = 1
print(b.a.x, b.a.x == 1)
b = libreproducer.ClassB2()
print('case4 B2', b.a.x)
a = b.a
a.x = 1
b.a = a
del a
print(b.a.x, b.a.x == 1)
b.a.x = 2
print(b.a.x, b.a.x == 2)
# it's not clear what's the right way to implement a python object in
# rust that references another python object, ClassB with the
# workaround() below, or ClassB2.
b = libreproducer.ClassB()
print('case4 B workaround', b.a.x)
b.workaround(1)
print(b.a.x, b.a.x == 1)