Always use basestring instead of str with isinstance().
authorZac Medico <zmedico@gentoo.org>
Sat, 7 Mar 2009 19:40:18 +0000 (19:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 7 Mar 2009 19:40:18 +0000 (19:40 -0000)
svn path=/main/trunk/; revision=12775

pym/_emerge/__init__.py
pym/portage/cache/template.py
pym/portage/mail.py
pym/portage/process.py

index f643cc3df5d0c6501cf9f89fe8a3f0314fd230e7..0b60e0fd27616265f6ce22b469fb6abcda4a8aea 100644 (file)
@@ -9728,7 +9728,7 @@ class JobStatusDisplay(object):
                        object.__setattr__(self, "_term_codes", term_codes)
                encoding = sys.getdefaultencoding()
                for k, v in self._term_codes.items():
-                       if not isinstance(v, str):
+                       if not isinstance(v, basestring):
                                self._term_codes[k] = v.decode(encoding, 'replace')
 
        def _init_term(self):
index 7fce8ef179e2b4c042e58d23922fc599ed277bb5..e782163384537a50ad4ee840979eb6fdad5ce24f 100644 (file)
@@ -169,7 +169,7 @@ class database(object):
                for key,match in match_dict.iteritems():
                        # XXX this sucks.
                        try:
-                               if isinstance(match, str):
+                               if isinstance(match, basestring):
                                        restricts[key] = re.compile(match).match
                                else:
                                        restricts[key] = re.compile(match[0],match[1]).match
index cf6ebd134e116a6ae3b3353d3c6fef85aa6ae0d9..72b4112649a39e1be7e224c37bc8385298fc1441 100644 (file)
@@ -17,7 +17,7 @@ def create_message(sender, recipient, subject, body, attachments=None):
                for x in attachments:
                        if isinstance(x, BaseMessage):
                                mymessage.attach(x)
-                       elif isinstance(x, str):
+                       elif isinstance(x, basestring):
                                mymessage.attach(TextMessage(x))
                        else:
                                raise portage.exception.PortageException("Can't handle type of attachment: %s" % type(x))
index 7c0fb342f3acfafae42c1b5e4c386ef245205b80..6f449c3d6da8b325918883acd6309d667e0b0f70 100644 (file)
@@ -175,7 +175,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
        """
 
        # mycommand is either a str or a list
-       if isinstance(mycommand, str):
+       if isinstance(mycommand, basestring):
                mycommand = mycommand.split()
 
        # If an absolute path to an executable file isn't given