Skip to content

Commit 0aaa07e

Browse files
gnofsjgarman
authored andcommitted
Return None for any missing BaseModel attribute
Accessing a missing attribute in BaseModel raises an AttributeError, but as this happens quite frequently with objects that otherwise contain valid data, it should not be enough to cause the API query to fail. Instead, we can safely return None in place of a missing attribute.
1 parent 45fb22b commit 0aaa07e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/cbapi/oldmodels.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ def _attribute(self, attrname, default=None):
141141
if attrname in self._info:
142142
return self._info[attrname]
143143

144-
if default is not None:
145-
return default
146-
147-
raise AttributeError()
144+
return default
148145

149146
def get(self, attrname, default_val=None):
150147
try:

0 commit comments

Comments
 (0)