File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 2121import shutil
2222import tempfile
2323from subprocess import Popen , PIPE
24+ import binascii
2425
2526from m64py .utils import which
2627
4748if HAS_7Z or LZMA_CMD : EXT_FILTER += " *.7z"
4849
4950ROM_TYPE = {
50- '80371240' : 'z64 (native)' ,
51- '37804012' : 'v64 (byteswapped)' ,
52- '40123780' : 'n64 (wordswapped)'
51+ b '80371240' : 'z64 (native)' ,
52+ b '37804012' : 'v64 (byteswapped)' ,
53+ b '40123780' : 'n64 (wordswapped)'
5354}
5455
5556
@@ -153,17 +154,17 @@ def get_filetype(self):
153154 fd = open (self .file , "rb" )
154155 magic = fd .read (4 )
155156 fd .close ()
156- if magic == 'PK\03 \04 ' :
157+ if magic == b 'PK\03 \04 ' :
157158 return ZIP
158- elif magic .startswith ('\037 \213 ' ):
159+ elif magic .startswith (b '\037 \213 ' ):
159160 return GZIP
160- elif magic .startswith ('BZh' ):
161+ elif magic .startswith (b 'BZh' ):
161162 return BZIP
162- elif magic == 'Rar!' :
163+ elif magic == b 'Rar!' :
163164 return RAR
164- elif magic == '7z\xbc \xaf ' :
165+ elif magic == b '7z\xbc \xaf ' :
165166 return LZMA
166- elif magic . encode ( 'hex' ) in ROM_TYPE .keys ():
167+ elif binascii . hexlify ( magic ) in ROM_TYPE .keys ():
167168 return ROM
168169 return None
169170
Original file line number Diff line number Diff line change 1919import signal
2020import ctypes as C
2121import subprocess
22+ import binascii
2223
2324from m64py .core .defs import *
2425from m64py .core .config import Config
@@ -295,7 +296,7 @@ def detach_plugins(self):
295296 def rom_open (self , romfile ):
296297 """Reads in a binary ROM image"""
297298 self .rom_length = len (romfile )
298- self .rom_type = ROM_TYPE [romfile [:4 ]. encode ( 'hex' )]
299+ self .rom_type = ROM_TYPE [binascii . hexlify ( romfile [:4 ])]
299300 romlength = C .c_int (self .rom_length )
300301 rombuffer = C .c_buffer (romfile )
301302 rval = self .m64p .CoreDoCommand (
You can’t perform that action at this time.
0 commit comments