Repository: libcloud Updated Branches: refs/heads/0.20.1 [created] d1cf93179
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/38b61eb1 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/38b61eb1 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/38b61eb1 Branch: refs/heads/0.20.1 Commit: 38b61eb13fcee91c1a172516da93a9c652b29024 Parents: 4087f45 Author: Greg Hill <greg.h...@rackspace.com> Authored: Tue Dec 15 10:42:47 2015 -0600 Committer: Eric Johnson <erjoh...@google.com> Committed: Fri Jan 15 15:22:04 2016 +0000 ---------------------------------------------------------------------- libcloud/dns/drivers/rackspace.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/38b61eb1/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)