File tree 3 files changed +9
-3
lines changed
3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -778,8 +778,9 @@ def doMain():
778
778
h (str (time .time ()))
779
779
if spec ["package" ] in develPkgs and "incremental_recipe" in spec :
780
780
h (spec ["incremental_recipe" ])
781
- incremental_hash = hashlib .sha1 (spec ["incremental_recipe" ]).hexdigest ()
782
- spec ["incremental_hash" ] = incremental_hash
781
+ ih = Hasher ()
782
+ ih (spec ["incremental_recipe" ])
783
+ spec ["incremental_hash" ] = ih .hexdigest ()
783
784
elif p in develPkgs :
784
785
h (spec .get ("devel_hash" ))
785
786
spec ["hash" ] = h .hexdigest ()
Original file line number Diff line number Diff line change @@ -284,6 +284,8 @@ class Hasher:
284
284
def __init__ (self ):
285
285
self .h = hashlib .sha1 ()
286
286
def __call__ (self , txt ):
287
- self .h .update (txt .encode ('utf-8' , 'ignore' ))
287
+ if not type (txt ) == bytes :
288
+ txt = txt .encode ('utf-8' , 'ignore' )
289
+ self .h .update (txt )
288
290
def hexdigest (self ):
289
291
return self .h .hexdigest ()
Original file line number Diff line number Diff line change @@ -120,10 +120,13 @@ def test_Hasher(self):
120
120
def test_UTF8_Hasher (self ):
121
121
h1 = Hasher ()
122
122
h2 = Hasher ()
123
+ h3 = Hasher ()
123
124
h1 (u'\ua000 ' )
124
125
h2 (u'\ua001 ' )
126
+ h3 (b'foo' )
125
127
self .assertEqual (h1 .hexdigest (), "2af8e41129115eb231a0af76ec5465d3a9184fc4" )
126
128
self .assertEqual (h2 .hexdigest (), "1619bcdbeff6828138ad9b6e43cc17e856457603" )
129
+ self .assertEqual (h3 .hexdigest (), "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" )
127
130
self .assertNotEqual (h1 .hexdigest (), h2 .hexdigest ())
128
131
129
132
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments