← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~daniel-thewatkins/cloud-init/+git/cloud-init:string_types into cloud-init:master


Dan Watkins has proposed merging ~daniel-thewatkins/cloud-init/+git/cloud-init:string_types into cloud-init:master.

Commit message:
util: don't determine string_types ourselves
six already provides this for us, and we're already paying the cost to
determine it there; no need to do it twice.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
Your team cloud-init commiters is requested to review the proposed merge of ~daniel-thewatkins/cloud-init/+git/cloud-init:string_types into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index 3a3fcdf..70e7a5c 100644
--- a/cloudinit/sources/DataSourceOVF.py
+++ b/cloudinit/sources/DataSourceOVF.py
@@ -15,6 +15,8 @@ import os
 import re
 import time
+import six
 from cloudinit import log as logging
 from cloudinit import sources
 from cloudinit import util
@@ -434,7 +436,7 @@ def maybe_cdrom_device(devname):
     if not devname:
         return False
-    elif not isinstance(devname, util.string_types):
+    elif not isinstance(devname, six.string_types):
         raise ValueError("Unexpected input for devname: %s" % devname)
     # resolve '..' and multi '/' elements
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 2be528a..e5403f7 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -51,11 +51,6 @@ from cloudinit import version
 from cloudinit.settings import (CFG_BUILTIN)
-    string_types = (basestring,)
-except NameError:
-    string_types = (str,)
 LOG = logging.getLogger(__name__)
@@ -125,7 +120,7 @@ def target_path(target, path=None):
     # return 'path' inside target, accepting target as None
     if target in (None, ""):
         target = "/"
-    elif not isinstance(target, string_types):
+    elif not isinstance(target, six.string_types):
         raise ValueError("Unexpected input for target: %s" % target)
         target = os.path.abspath(target)

Follow ups