diff options
author | Jordan Brière <github@jordanbriere.com> | 2022-04-12 14:48:51 -0400 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2022-04-12 20:51:34 +0200 |
commit | 5db0e66d5bb26f6cf4030b4f8a6a5c6304a7b508 (patch) | |
tree | 70f043c16ec758c8b5fe1295b04efbd26de63686 | |
parent | ae4ade8daeae206db68583f2f4b9c1cbce9cba75 (diff) | |
download | cython-5db0e66d5bb26f6cf4030b4f8a6a5c6304a7b508.tar.gz |
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.
-rw-r--r-- | Cython/Shadow.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Cython/Shadow.py b/Cython/Shadow.py index fb662dc05..0391b3b86 100644 --- a/Cython/Shadow.py +++ b/Cython/Shadow.py @@ -305,7 +305,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)} |