File remove-six-dep.patch of Package python-ldappool
Index: ldappool-3.0.0/ldappool/__init__.py
===================================================================
--- ldappool-3.0.0.orig/ldappool/__init__.py
+++ ldappool-3.0.0/ldappool/__init__.py
@@ -35,7 +35,6 @@
# ***** END LICENSE BLOCK *****
""" LDAP Connection Pool.
"""
-import codecs
from contextlib import contextmanager
import logging
from threading import RLock
@@ -45,29 +44,26 @@ import ldap
from ldap.ldapobject import ReconnectLDAPObject
from prettytable import PrettyTable
import re
-import six
-from six import PY2
log = logging.getLogger(__name__)
-_utf8_encoder = codecs.getencoder('utf-8')
def utf8_encode(value):
"""Encode a basestring to UTF-8.
- If the string is unicode encode it to UTF-8, if the string is
- str then assume it's already encoded. Otherwise raise a TypeError.
+ If the value is string, encode it to UTF-8, if the value is
+ bytes then assume it's already encoded. Otherwise raise a TypeError.
:param value: A basestring
:returns: UTF-8 encoded version of value
:raises TypeError: If value is not basestring
"""
- if isinstance(value, six.text_type):
- return _utf8_encoder(value)[0]
- elif isinstance(value, six.binary_type):
+ if isinstance(value, str):
+ return value.encode('utf-8')
+ elif isinstance(value, bytes):
return value
else:
- raise TypeError("bytes or Unicode expected, got %s"
+ raise TypeError("bytes or str expected, got %s"
% type(value).__name__)
@@ -169,9 +165,6 @@ class ConnectionManager(object):
return len(self._pool)
def _match(self, bind, passwd):
- if passwd is not None:
- if PY2:
- passwd = utf8_encode(passwd)
with self._pool_lock:
inactives = []
@@ -242,9 +235,6 @@ class ConnectionManager(object):
:raises BackendError: If unable to connect to LDAP
"""
connected = False
- if passwd is not None:
- if PY2:
- passwd = utf8_encode(passwd)
# If multiple server URIs have been provided, loop through
# each one in turn in case of connection failures (server down,