From 37c2311d1b10585fd667c19db32096b9bbefbefd Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Mon, 8 May 2017 22:26:48 -0700 Subject: [PATCH] Fixed some python 3 bytes/string issues --- atrcopy/ataridos.py | 3 ++- atrcopy/cartridge.py | 2 +- atrcopy/dos33.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/atrcopy/ataridos.py b/atrcopy/ataridos.py index b573858..f5b3f0f 100644 --- a/atrcopy/ataridos.py +++ b/atrcopy/ataridos.py @@ -102,7 +102,8 @@ class AtariDosDirent(Dirent): self.parse_raw_dirent(image, bytes) def __str__(self): - return "File #%-2d (%s) %03d %-8s%-3s %03d" % (self.file_num, self.summary, self.starting_sector, str(self.basename), str(self.ext), self.num_sectors) + # return (b'File #%-2d (%s) %03d %-8s%-3s %03d' % (self.file_num, self.summary.encode("utf-8"), self.starting_sector, self.basename, self.ext, self.num_sectors)).decode("utf-8") + return "File #%-2d (%s) %03d %-8s%-3s %03d" % (self.file_num, self.summary, self.starting_sector, self.basename.decode("utf-8"), self.ext.decode("utf-8"), self.num_sectors) def __eq__(self, other): return self.__class__ == other.__class__ and self.filename == other.filename and self.starting_sector == other.starting_sector and self.num_sectors == other.num_sectors diff --git a/atrcopy/cartridge.py b/atrcopy/cartridge.py index 78f0693..1ee7e37 100644 --- a/atrcopy/cartridge.py +++ b/atrcopy/cartridge.py @@ -166,7 +166,7 @@ class A8CartHeader(object): def to_array(self): raw = np.zeros([16], dtype=np.uint8) values = raw.view(dtype=self.format)[0] - values[0] = 'CART' + values[0] = b'CART' values[1] = self.cart_type values[2] = self.crc values[3] = 0 diff --git a/atrcopy/dos33.py b/atrcopy/dos33.py index adc82af..d7c24fc 100644 --- a/atrcopy/dos33.py +++ b/atrcopy/dos33.py @@ -180,7 +180,7 @@ class Dos33Dirent(Dirent): self.parse_raw_dirent(image, bytes) def __str__(self): - return "File #%-2d (%s) %03d %-30s %03d %03d" % (self.file_num, self.summary, self.num_sectors, self.filename, self.track, self.sector) + return "File #%-2d (%s) %03d %-30s %03d %03d" % (self.file_num, self.summary, self.num_sectors, self.filename.decode("utf-8"), self.track, self.sector) def __eq__(self, other): return self.__class__ == other.__class__ and self.filename == other.filename and self.track == other.track and self.sector == other.sector and self.num_sectors == other.num_sectors