Skip to content

Commit d0a0e62

Browse files
blr246cwacek
authored andcommitted
Make property setting robust to inheritance. (#54)
Use `getattr(self.__class__, property_name)` to get properties and set them. This is compatible with using a class builder as a base class. In my case, I'm extending class builders so that I can add constants for enum values directly to the class definition rather than having to use strings.
1 parent 776a84c commit d0a0e62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python_jsonschema_objects/classbuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def __setattr__(self, name, val):
178178
# The property does special validation, so we actually need to
179179
# run its setter. We get it from the class definition and call
180180
# it directly. XXX Heinous.
181-
prop = self.__class__.__dict__[self.__prop_names__[name]]
181+
prop = getattr(self.__class__, self.__prop_names__[name])
182182
prop.fset(self, val)
183183
else:
184184
# This is an additional property of some kind

0 commit comments

Comments
 (0)