From 26a42aeddfc5da577d6d724ad94ac630096d0214 Mon Sep 17 00:00:00 2001 From: wangqi Date: Mon, 23 Apr 2018 02:32:44 +0000 Subject: [PATCH] Replace basestring with six.string_types https://wiki.openstack.org/wiki/Python3 Change-Id: I09ceb7c4819573f404359af5200e990b1e6070e2 --- gceapi/api/common.py | 3 ++- gceapi/context.py | 3 ++- gceapi/tests/unit/test.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gceapi/api/common.py b/gceapi/api/common.py index 62c3714..e1c79cf 100644 --- a/gceapi/api/common.py +++ b/gceapi/api/common.py @@ -21,6 +21,7 @@ from webob import exc from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils +import six from gceapi.api import clients from gceapi.api import operation_api @@ -249,7 +250,7 @@ class Controller(object): """Returns standard format for given date.""" if date_string is None: return None - if isinstance(date_string, basestring): + if isinstance(date_string, six.string_types): date_string = timeutils.parse_isotime(date_string) return date_string.strftime('%Y-%m-%dT%H:%M:%SZ') diff --git a/gceapi/context.py b/gceapi/context.py index a441b2f..dd3ca8e 100644 --- a/gceapi/context.py +++ b/gceapi/context.py @@ -22,6 +22,7 @@ from oslo_context import context from oslo_log import log as logging from oslo_utils import timeutils +import six from gceapi import exception from gceapi.i18n import _ @@ -72,7 +73,7 @@ class RequestContext(context.RequestContext): self.remote_address = remote_address if not timestamp: timestamp = timeutils.utcnow() - if isinstance(timestamp, basestring): + if isinstance(timestamp, six.string_types): timestamp = timeutils.parse_strtime(timestamp) self.timestamp = timestamp diff --git a/gceapi/tests/unit/test.py b/gceapi/tests/unit/test.py index ad0dc4e..a34ed5c 100644 --- a/gceapi/tests/unit/test.py +++ b/gceapi/tests/unit/test.py @@ -32,6 +32,7 @@ import fixtures import mox from oslo_config import cfg from oslo_log import log as logging +import six import stubout import testtools @@ -155,7 +156,7 @@ class TestCase(testtools.TestCase): self.assertIn(k, d2) v2 = d2[k] if(isinstance(v1, collections.Iterable) and - not isinstance(v1, basestring)): + not isinstance(v1, six.string_types)): self.assertItemsEqual(v1, v2, msg) else: self.assertEqual(v1, v2, msg)