Skip to content

Commit 8d92f17

Browse files
author
Hart
committed
neorpython - fixed if @Property get method had the same name as property
1 parent 7fbdf05 commit 8d92f17

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

examples-rpython/test9-llvm-vectors.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def run_test(x1,y1,z1, x2,y2,z2):
5555
global G
5656
res = test(x1,y1,z1, x2,y2,z2)
5757
G.append( res )
58+
if len( G ) == 4:
59+
print('end of llvm benchmark:', time.time()-start)
60+
print('test result:', G)
61+
5862
for i in range(10):
5963
G = []
6064
start = time.time()
@@ -63,10 +67,8 @@ def run_test(x1,y1,z1, x2,y2,z2):
6367
threading._start_new_thread( run_test, (0.3, 0.3, 0.3, 0.3, 0.3, 0.3) )
6468
threading._start_new_thread( run_test, (0.3, 0.3, 0.3, 0.3, 0.3, 0.3) )
6569
while len(G) != 4:
66-
time.sleep(0.01)
67-
print('end of llvm benchmark:', time.time()-start)
68-
print('test result:', G)
69-
70+
time.sleep(1.0)
71+
print('thread test done')
7072

7173

7274
else:

rpythonic/neorpython.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def make_rpython_compatible( translator, delete_class_properties=True, debug=Tru
379379

380380
if op.opname == 'setattr':
381381
func_name = prop.fset.func_name
382+
assert func_name != prop.fget.func_name
382383
elif op.opname == 'getattr':
383384
func_name = prop.fget.func_name
384385

@@ -395,7 +396,12 @@ def make_rpython_compatible( translator, delete_class_properties=True, debug=Tru
395396
if delete_class_properties:
396397
## this is required to avoid "degenerate to SomeObject" error by the annotation phase
397398
for cls in class_props:
398-
for name in class_props[ cls ]: delattr( cls, name )
399+
for name in class_props[ cls ]:
400+
prop = getattr(cls, name)
401+
assert type(prop) is property
402+
delattr( cls, name )
403+
if prop.fget.func_name == name:
404+
setattr( cls, name, prop.fget )
399405

400406
return class_props # returns class props to be removed before annotation
401407

rpythonic/rpythonic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RPythonic - April, 2012
33
# By Brett, bhartsho@yahoo.com
44
# License: BSD
5-
VERSION = '0.4.7a'
5+
VERSION = '0.4.7b'
66

77
_doc_ = '''
88
NAME

0 commit comments

Comments
 (0)