@@ -158,7 +158,7 @@ def encodeAddress(version, stream, ripe):
158158 raise Exception (
159159 'Programming error in encodeAddress: The length of'
160160 ' a given ripe hash was not 20.' )
161- ripe = ripe .lstrip ('\x00 ' )
161+ ripe = ripe .lstrip ('\x00 ' . encode ( 'utf-8' ) )
162162
163163 storedBinaryData = encodeVarint (version ) + encodeVarint (stream ) + ripe
164164
@@ -180,7 +180,6 @@ def decodeAddress(address):
180180 data (almost certainly a ripe hash))
181181 """
182182 # pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches
183-
184183 address = str (address ).strip ()
185184
186185 if address [:3 ] == 'BM-' :
@@ -192,7 +191,7 @@ def decodeAddress(address):
192191 return status , 0 , 0 , ''
193192 # after converting to hex, the string will be prepended
194193 # with a 0x and appended with a L
195- hexdata = hex (integer )[2 :- 1 ]
194+ hexdata = hex (integer )[2 :]
196195
197196 if len (hexdata ) % 2 != 0 :
198197 hexdata = '0' + hexdata
@@ -248,7 +247,7 @@ def decodeAddress(address):
248247 embeddedRipeData
249248 elif len (embeddedRipeData ) == 18 :
250249 return status , addressVersionNumber , streamNumber , \
251- '\x00 \x00 ' + embeddedRipeData
250+ '\x00 \x00 ' . encode ( 'utf-8' ) + embeddedRipeData
252251 elif len (embeddedRipeData ) < 18 :
253252 return 'ripetooshort' , 0 , 0 , ''
254253 elif len (embeddedRipeData ) > 20 :
@@ -265,7 +264,8 @@ def decodeAddress(address):
265264 return 'ripetoolong' , 0 , 0 , ''
266265 elif len (embeddedRipeData ) < 4 :
267266 return 'ripetooshort' , 0 , 0 , ''
268- x00string = '\x00 ' * (20 - len (embeddedRipeData ))
267+ x00string = '\x00 ' .encode ('utf-8' ) * (20 - len (embeddedRipeData ))
268+
269269 return status , addressVersionNumber , streamNumber , \
270270 x00string + embeddedRipeData
271271
0 commit comments