Repository: libcloud Updated Branches: refs/heads/trunk a5ff3dbb3 -> 3e85cf159
Use hasattr rather than getattr to check for existence I forgot getattr throws an exception. This should have been a hasattr. Additionally added a check to make sure it's a dict before treating it as such. Closes #659 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3e85cf15 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3e85cf15 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3e85cf15 Branch: refs/heads/trunk Commit: 3e85cf1591c9ccb07ec779ccb6a589e56534799d Parents: a5ff3db Author: Greg Hill <[email protected]> Authored: Tue Dec 15 10:42:47 2015 -0600 Committer: anthony-shaw <[email protected]> Committed: Wed Dec 16 15:29:35 2015 +1100 ---------------------------------------------------------------------- libcloud/dns/drivers/rackspace.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/3e85cf15/libcloud/dns/drivers/rackspace.py ---------------------------------------------------------------------- diff --git a/libcloud/dns/drivers/rackspace.py b/libcloud/dns/drivers/rackspace.py index 1e05206..4507fb1 100644 --- a/libcloud/dns/drivers/rackspace.py +++ b/libcloud/dns/drivers/rackspace.py @@ -667,9 +667,10 @@ def _rackspace_result_has_more(response, result_length, limit): def _check_ptr_extra_fields(device_or_record): - if not (getattr(device_or_record, 'extra') and + if not (hasattr(device_or_record, 'extra') and + isinstance(device_or_record.extra, dict) and device_or_record.extra.get('uri') is not None and device_or_record.extra.get('service_name') is not None): raise LibcloudError("Can't create PTR Record for %s because it " "doesn't have a 'uri' and 'service_name' in " - "'extra'") + "'extra'" % device_or_record)
