From 270519e645c18f14ab628070806bf543bb199131 Mon Sep 17 00:00:00 2001 From: stroeder Date: Sat, 18 Nov 2017 18:47:21 +0000 Subject: [PATCH] module ldif now uses functions b64encode() and b64decode() --- CHANGES | 1 + Lib/ldif.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c5c3320..aad549c 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ Lib/ * method .decodeControlValue() of SSSResponseControl and VLVResponseControl does not set class attribute result_code anymore * always use bytes() for UUID() constructor in ldap.syncrepl +* module ldif now uses functions b64encode() and b64decode() Tests/ * scripts do not directly call SlapdTestCase.setUpClass() anymore diff --git a/Lib/ldif.py b/Lib/ldif.py index 8b1cd28..e06cbd3 100644 --- a/Lib/ldif.py +++ b/Lib/ldif.py @@ -21,7 +21,10 @@ 'LDIFCopy', ] -import urlparse,urllib,base64,re +import urlparse +import urllib +import re +from base64 import b64encode, b64decode try: from cStringIO import StringIO @@ -139,7 +142,7 @@ def _unparseAttrTypeandValue(self,attr_type,attr_value): """ if self._needs_base64_encoding(attr_type,attr_value): # Encode with base64 - self._unfold_lines(':: '.join([attr_type,base64.encodestring(attr_value).replace('\n','')])) + self._unfold_lines(':: '.join([attr_type, b64encode(attr_value).replace('\n','')])) else: self._unfold_lines(': '.join([attr_type,attr_value])) return # _unparseAttrTypeandValue() @@ -277,7 +280,7 @@ def __init__( self.records_read = 0 self.changetype_counter = {}.fromkeys(CHANGE_TYPES,0) # Store some symbols for better performance - self._base64_decodestring = base64.decodestring + self._b64decode = b64decode # Read very first line try: self._last_line = self._readline() @@ -346,7 +349,7 @@ def _next_key_and_value(self): attr_value = unfolded_line[colon_pos+2:].lstrip() elif value_spec=='::': # attribute value needs base64-decoding - attr_value = self._base64_decodestring(unfolded_line[colon_pos+2:]) + attr_value = self._b64decode(unfolded_line[colon_pos+2:]) elif value_spec==':<': # fetch attribute value from URL url = unfolded_line[colon_pos+2:].strip()