Return-Path: X-Original-To: apmail-libcloud-notifications-archive@www.apache.org Delivered-To: apmail-libcloud-notifications-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 42F3718D14 for ; Fri, 15 Jan 2016 15:49:00 +0000 (UTC) Received: (qmail 41175 invoked by uid 500); 15 Jan 2016 15:49:00 -0000 Delivered-To: apmail-libcloud-notifications-archive@libcloud.apache.org Received: (qmail 41137 invoked by uid 500); 15 Jan 2016 15:49:00 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 41121 invoked by uid 500); 15 Jan 2016 15:49:00 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 41118 invoked by uid 99); 15 Jan 2016 15:49:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jan 2016 15:49:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 01486E07F6; Fri, 15 Jan 2016 15:48:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: erjohnso@apache.org To: commits@libcloud.apache.org Date: Fri, 15 Jan 2016 15:48:59 -0000 Message-Id: <8cae4746a8b044e88d8004c89c543629@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] libcloud git commit: Use hasattr rather than getattr to check for existence 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 Authored: Tue Dec 15 10:42:47 2015 -0600 Committer: Eric Johnson 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)