diff options
| author | Christian Heimes <cheimes@redhat.com> | 2018-09-26 12:39:56 +0200 |
|---|---|---|
| committer | Christian Heimes <cheimes@redhat.com> | 2018-09-27 16:11:18 +0200 |
| commit | 61156b0a50dc4eddff46a1352574e04d298e9af9 (patch) | |
| tree | e6ccab4b495d5eb570ab0e7d234b57508a50fb31 /ipapython | |
| parent | ea396528b7e9575b5fcf4902ce9211cf0a67fcc6 (diff) | |
| download | freeipa-61156b0a50dc4eddff46a1352574e04d298e9af9.tar.gz freeipa-61156b0a50dc4eddff46a1352574e04d298e9af9.tar.xz freeipa-61156b0a50dc4eddff46a1352574e04d298e9af9.zip | |
Py3: Replace six.text_type with str
On Python 3, six.text_type (singular) is an alias for str.
See: https://pagure.io/freeipa/issue/7715
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
Diffstat (limited to 'ipapython')
| -rw-r--r-- | ipapython/directivesetter.py | 4 | ||||
| -rw-r--r-- | ipapython/dn.py | 8 | ||||
| -rw-r--r-- | ipapython/ipaldap.py | 4 | ||||
| -rw-r--r-- | ipapython/ipautil.py | 6 |
4 files changed, 10 insertions, 12 deletions
diff --git a/ipapython/directivesetter.py b/ipapython/directivesetter.py index 064766d8c..b03c580ee 100644 --- a/ipapython/directivesetter.py +++ b/ipapython/directivesetter.py @@ -2,8 +2,6 @@ # Copyright (C) 2018 FreeIPA Contributors see COPYING for license # -import six - import io import os import re @@ -47,7 +45,7 @@ class DirectiveSetter: fd, name = tempfile.mkstemp(prefix=prefix, dir=directory, text=True) with io.open(fd, mode='w', closefd=True) as f: for line in self.lines: - if not isinstance(line, six.text_type): + if not isinstance(line, str): line = line.decode('utf-8') f.write(line) self.lines = None diff --git a/ipapython/dn.py b/ipapython/dn.py index 1fca45232..6747a0ece 100644 --- a/ipapython/dn.py +++ b/ipapython/dn.py @@ -454,7 +454,7 @@ def _normalize_ava_input(val): if six.PY3 and isinstance(val, bytes): raise TypeError('expected str, got bytes: %r' % val) elif not isinstance(val, str): - val = val_encode(six.text_type(val)) + val = val_encode(str(val)) elif six.PY2 and isinstance(val, unicode): val = val.encode('utf-8') return val @@ -882,7 +882,7 @@ class RDN: if len(self._avas) == 0: raise IndexError("No AVA's in this RDN") - self._avas[0][0] = val_encode(six.text_type(new_attr)) + self._avas[0][0] = val_encode(str(new_attr)) attr = property(_get_attr) @@ -894,7 +894,7 @@ class RDN: def _set_value(self, new_value): if len(self._avas) == 0: raise IndexError("No AVA's in this RDN") - self._avas[0][1] = val_encode(six.text_type(new_value)) + self._avas[0][1] = val_encode(str(new_value)) value = property(_get_value) @@ -1114,7 +1114,7 @@ class DN: def _rdns_from_value(self, value): if isinstance(value, str): try: - if isinstance(value, six.text_type): + if isinstance(value, str): value = val_encode(value) rdns = str2dn(value) except DECODING_ERROR: diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index a35c94c27..45f78a108 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -910,7 +910,7 @@ class LDAPClient: else: return b'FALSE' elif isinstance(val, (unicode, int, Decimal, DN, Principal)): - return six.text_type(val).encode('utf-8') + return str(val).encode('utf-8') elif isinstance(val, DNSName): return val.to_text().encode('ascii') elif isinstance(val, bytes): @@ -1295,7 +1295,7 @@ class LDAPClient: value = u'\\'.join( value[i:i+2] for i in six.moves.range(-2, len(value), 2)) else: - value = six.text_type(value) + value = str(value) value = ldap.filter.escape_filter_chars(value) if not exact: diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index dd0da4196..2f4209cff 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -1441,12 +1441,12 @@ if six.PY2: """ if isinstance(value, six.binary_type): return value.decode(sys.getfilesystemencoding()) - elif isinstance(value, six.text_type): + elif isinstance(value, str): return value else: raise TypeError("expect {0} or {1}, not {2}".format( six.binary_type.__name__, - six.text_type.__name__, + str.__name__, type(value).__name__)) else: fsdecode = os.fsdecode #pylint: disable=no-member @@ -1522,7 +1522,7 @@ def decode_json(data): # default return 'utf-8' - if isinstance(data, six.text_type): + if isinstance(data, str): return data return data.decode(detect_encoding(data), 'surrogatepass') |
