@@ -419,23 +419,25 @@ def _deserialize(self, stream):
419419next_line = None
420420while True :
421421parent_line = readline ()
422- if not parent_line .startswith ('parent' ):
422+ if not parent_line .startswith (b 'parent' ):
423423next_line = parent_line
424424break
425425# END abort reading parents
426- self .parents .append (type (self )(self .repo ,hex_to_bin (parent_line .split ()[- 1 ])))
426+ self .parents .append (type (self )(self .repo ,hex_to_bin (parent_line .split ()[- 1 ]. decode ( 'ascii' ) )))
427427# END for each parent line
428428self .parents = tuple (self .parents )
429429
430- self .author ,self .authored_date ,self .author_tz_offset = parse_actor_and_date (next_line )
431- self .committer ,self .committed_date ,self .committer_tz_offset = parse_actor_and_date (readline ())
430+ # we don't know actual author encoding before we have parsed it, so keep the lines around
431+ author_line = next_line
432+ committer_line = readline ()
432433
433434# we might run into one or more mergetag blocks, skip those for now
434435next_line = readline ()
435- while next_line .startswith ('mergetag ' ):
436+ while next_line .startswith (b 'mergetag ' ):
436437next_line = readline ()
437438while next_line .startswith (' ' ):
438439next_line = readline ()
440+ # end skip mergetags
439441
440442# now we can have the encoding line, or an empty line followed by the optional
441443# message.
@@ -444,39 +446,40 @@ def _deserialize(self, stream):
444446# read headers
445447enc = next_line
446448buf = enc .strip ()
447- while buf != "" :
448- if buf [0 :10 ]== "encoding " :
449- self .encoding = buf [buf .find (' ' )+ 1 :]
450- elif buf [0 :7 ]== "gpgsig " :
451- sig = buf [buf .find (' ' )+ 1 :]+ "\n "
449+ while buf :
450+ if buf [0 :10 ]== b "encoding " :
451+ self .encoding = buf [buf .find (' ' )+ 1 :]. decode ( 'ascii' )
452+ elif buf [0 :7 ]== b "gpgsig " :
453+ sig = buf [buf .find (b ' ' )+ 1 :]+ b "\n "
452454is_next_header = False
453455while True :
454456sigbuf = readline ()
455- if sigbuf == "" :
457+ if not sigbuf :
456458break
457- if sigbuf [0 :1 ]!= " " :
459+ if sigbuf [0 :1 ]!= b " " :
458460buf = sigbuf .strip ()
459461is_next_header = True
460462break
461463sig += sigbuf [1 :]
462- self .gpgsig = sig .rstrip ("\n " )
464+ # end read all signature
465+ self .gpgsig = sig .rstrip (b"\n " ).decode ('ascii' )
463466if is_next_header :
464467continue
465468buf = readline ().strip ()
466-
467469# decode the authors name
470+
468471try :
469- self .author .name = self .author .name .decode (self .encoding )
472+ self .author ,self .authored_date ,self .author_tz_offset = \
473+ parse_actor_and_date (author_line .decode (self .encoding ))
470474except UnicodeDecodeError :
471- log .error ("Failed to decode authorname '%s' using encoding %s" ,self . author . name ,self .encoding ,
475+ log .error ("Failed to decode authorline '%s' using encoding %s" ,author_line ,self .encoding ,
472476exc_info = True )
473- # END handle author's encoding
474477
475- # decode committer name
476478try :
477- self .committer .name = self .committer .name .decode (self .encoding )
479+ self .committer ,self .committed_date ,self .committer_tz_offset = \
480+ parse_actor_and_date (committer_line .decode (self .encoding ))
478481except UnicodeDecodeError :
479- log .error ("Failed to decode committername '%s' using encoding %s" ,self . committer . name ,self .encoding ,
482+ log .error ("Failed to decode committerline '%s' using encoding %s" ,committer_line ,self .encoding ,
480483exc_info = True )
481484# END handle author's encoding
482485
@@ -488,6 +491,7 @@ def _deserialize(self, stream):
488491except UnicodeDecodeError :
489492log .error ("Failed to decode message '%s' using encoding %s" ,self .message ,self .encoding ,exc_info = True )
490493# END exception handling
494+
491495return self
492496
493497#} END serializable implementation