PEP8 remove direct type comparisons

Fixes bug #910763

According to PEP8,
- Object type comparisons should always use isinstance() instead
      of comparing types directly.

        Yes: if isinstance(obj, int):

        No: if type(obj) is type(1):

      When checking if an object is a string, keep in mind that it might be a
      unicode string too! In Python 2.3, str and unicode have a common base
      class, basestring, so you can do:

        if isinstance(obj, basestring):

Change-Id: I7c0fdecf99872f5b8f72b2c2ed4f5c539c33def1
This commit is contained in:
lzyeval
2012-01-02 17:31:36 +08:00
parent 2bb09d22e0
commit 38b630a93a
8 changed files with 12 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ def _clean(attr):
"""Clean attr for insertion into ldap"""
if attr is None:
return None
if type(attr) is unicode:
if isinstance(attr, unicode):
return str(attr)
return attr