Commit 54546b90 authored by Jordan Brière's avatar Jordan Brière Committed by GitHub

Fix UnionType.__setattr__ in Shadow.py (GH-4727)

The condition should only evaluate to True when assigning __dict__, but it currently does for _, d, i, etc. as well as resulting in the following potential issues:

* Non-member are being assigned to the object instead of raising.
* The one-field rule can be bypassed.
* Valid members that pass the condition are being assigned raw and are never cast to the specified type.
parent 9cff1408
......@@ -337,7 +337,7 @@ class UnionType(CythonType):
setattr(self, key, value)
def __setattr__(self, key, value):
if key in '__dict__':
if key == '__dict__':
CythonType.__setattr__(self, key, value)
elif key in self._members:
self.__dict__ = {key: cast(self._members[key], value)}
......
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