Commit b05f5111 authored by Xavier Thompson's avatar Xavier Thompson

Fix automatic locking for nested cypclass attribute access.

Example of nested attribute access:
```
a.b.c.d
```

Before this commit, only the outermost object was properly locked when
accessing its attribute. For the inner objects which are themselves
attributes of outermore objects, the locks were released immediately
after being acquired and before accessing the object's attribute.

Pseudo code example:
```
lock a
temp_b = a.b
lock temp_b
unlock temp_b
temp_c = temp_b.c
lock temp_c
unlock temp_c
temp_c.d
unlock a
```

instead of:
```
lock a
temp_b = a.b
lock temp_b
temp_c = temp_b.c
lock temp_c
temp_c.d
unlock temp_c
unlock temp_b
unlock a
```
parent fe252709
......@@ -14192,10 +14192,24 @@ class CoerceToLockedTempNode(CoerceToTempNode):
else:
code.putln("Cy_wlock_guard %s(%s, %s);" % (guard_code, self.result(), context))
def generate_subexpr_disposal_code(self, code):
# Postponed until this node is disposed of.
# See ExprNode.generate_evaluation_code.
return
def free_subexpr_temps(self, code):
# Postponed until this node is disposed of.
# See ExprNode.generate_evaluation_code.
return
def generate_disposal_code(self, code):
# Close the scope to release the lock.
code.putln("}")
super(CoerceToLockedTempNode, self).generate_disposal_code(code)
# Dispose of and release postponed subexpressions.
ExprNode.generate_subexpr_disposal_code(self, code)
ExprNode.free_subexpr_temps(self, code)
# Dispose of and release this temporary.
ExprNode.generate_disposal_code(self, code)
class ProxyNode(CoercionNode):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment