@@ -214,7 +214,7 @@ def itn(n, digits=8, format=DEFAULT_FORMAT):
214214 # encoding, the following digits-1 bytes are a big-endian
215215 # representation. This allows values up to (256**(digits-1))-1.
216216 if 0 <= n < 8 ** (digits - 1 ):
217- s = bytes ("%0*o" % (digits - 1 , n )) + NUL
217+ s = bytes ("%0*o" % (digits - 1 , n ), "ascii" ) + NUL
218218 else :
219219 if format != GNU_FORMAT or n >= 256 ** (digits - 1 ):
220220 raise ValueError ("overflow in number field" )
@@ -604,7 +604,7 @@ def read(self, size):
604604 def getcomptype (self ):
605605 if self .buf .startswith (b"\037 \213 \010 " ):
606606 return "gz"
607- if self .buf .startswith ("BZh91" ):
607+ if self .buf .startswith (b "BZh91" ):
608608 return "bz2"
609609 return "tar"
610610
@@ -1108,7 +1108,7 @@ def _create_header(info, format, encoding, errors):
11081108
11091109 buf = struct .pack ("%ds" % BLOCKSIZE , b"" .join (parts ))
11101110 chksum = calc_chksums (buf [- BLOCKSIZE :])[0 ]
1111- buf = buf [:- 364 ] + bytes ("%06o\0 " % chksum ) + buf [- 357 :]
1111+ buf = buf [:- 364 ] + bytes ("%06o\0 " % chksum , "ascii" ) + buf [- 357 :]
11121112 return buf
11131113
11141114 @staticmethod
@@ -1155,7 +1155,7 @@ def _create_pax_generic_header(cls, pax_headers, type):
11551155 if n == p :
11561156 break
11571157 p = n
1158- records += bytes (str (p )) + b" " + keyword + b"=" + value + b"\n "
1158+ records += bytes (str (p ), "ascii" ) + b" " + keyword + b"=" + value + b"\n "
11591159
11601160 # We use a hardcoded "././@PaxHeader" name like star does
11611161 # instead of the one that POSIX recommends.
0 commit comments