diff --git a/atrcopy/dos33.py b/atrcopy/dos33.py index dcdf21b..96b1010 100644 --- a/atrcopy/dos33.py +++ b/atrcopy/dos33.py @@ -251,7 +251,7 @@ class Dos33Dirent(Dirent): values[1] = self.sector values[2] = self.flag n = min(len(self.filename), 30) - data[3:3+n] = np.fromstring(self.filename.encode("ascii"), dtype=np.uint8) | 0x80 + data[3:3+n] = np.frombuffer(self.filename.encode("ascii"), dtype=np.uint8) | 0x80 data[3+n:] = ord(' ') | 0x80 if self.deleted: data[0x20] = self.track diff --git a/atrcopy/kboot.py b/atrcopy/kboot.py index 0728bb5..010d74a 100644 --- a/atrcopy/kboot.py +++ b/atrcopy/kboot.py @@ -86,7 +86,7 @@ xexboot_header = b'\x00\x03\x00\x07\r\x07L\r\x07\x1c[\x00\x00\xa0\x00\x8c\t\x03\ def insert_bytes(data, offset, string, color): - s = np.fromstring(string.upper(), dtype=np.uint8) - 32 # convert to internal + s = np.frombuffer(string.upper(), dtype=np.uint8) - 32 # convert to internal s = s | color count = len(s) tx = offset + (20 - count) // 2 @@ -103,7 +103,7 @@ def add_xexboot_header(bytes, bootcode=None, title=b"DEMO", author=b"an atari us paragraphs = padded_size // 16 if bootcode is None: - bootcode = np.fromstring(xexboot_header, dtype=np.uint8) + bootcode = np.copy(np.frombuffer(xexboot_header, dtype=np.uint8)) else: # don't insert title or author in user supplied bootcode; would have to # assume that the user supplied everything desired in their own code! diff --git a/atrcopy/mame.py b/atrcopy/mame.py index 370849a..20850f1 100644 --- a/atrcopy/mame.py +++ b/atrcopy/mame.py @@ -46,7 +46,7 @@ class MameZipImage(DiskImageBase): segment_info = [] offset = 0 for item in zf.infolist(): - rom = np.fromstring(zf.open(item).read(), dtype=np.uint8) + rom = np.frombuffer(zf.open(item).read(), dtype=np.uint8) roms.append(rom) segment_info.append((offset, item.file_size, item.filename, item.CRC)) offset += item.file_size diff --git a/atrcopy/standard_delivery.py b/atrcopy/standard_delivery.py index fe2a2f1..ccd8622 100644 --- a/atrcopy/standard_delivery.py +++ b/atrcopy/standard_delivery.py @@ -165,7 +165,7 @@ from . fstbt import fstbt def get_fstbt_code(data, address_list, run_addr): pointer = len(fstbt) - data[0:pointer] = np.fromstring(fstbt, dtype=np.uint8) + data[0:pointer] = np.frombuffer(fstbt, dtype=np.uint8) hi, lo = divmod(run_addr, 256) data[pointer:pointer + 2] = (lo, hi) address_list.append(0xc0) # last sector flag diff --git a/atrcopy/utils.py b/atrcopy/utils.py index ad022e9..3bf1790 100644 --- a/atrcopy/utils.py +++ b/atrcopy/utils.py @@ -29,7 +29,7 @@ def to_numpy(value): if type(value) is np.ndarray: return value elif type(value) is bytes: - return np.fromstring(value, dtype=np.uint8) + return np.copy(np.frombuffer(value, dtype=np.uint8)) elif type(value) is list: return np.asarray(value, dtype=np.uint8) raise TypeError("Can't convert to numpy data") diff --git a/test/test_add_file.py b/test/test_add_file.py index afee838..eca940d 100644 --- a/test/test_add_file.py +++ b/test/test_add_file.py @@ -25,7 +25,7 @@ class BaseFilesystemModifyTest: filename = "%s%d.BIN" % (prefix, count) self.image.write_file(filename, None, data) assert len(self.image.files) == orig_num_files + count - data2 = np.fromstring(self.image.find_file(filename), dtype=np.uint8) + data2 = np.frombuffer(self.image.find_file(filename), dtype=np.uint8) assert np.array_equal(data, data2[0:len(data)]) count += 1 @@ -33,7 +33,7 @@ class BaseFilesystemModifyTest: count = 1 for data in entries: filename = "%s%d.BIN" % (prefix, count) - data2 = np.fromstring(self.image.find_file(filename), dtype=np.uint8) + data2 = np.frombuffer(self.image.find_file(filename), dtype=np.uint8) assert np.array_equal(data, data2[0:len(data)]) count += 1 filenames.append(filename) @@ -50,7 +50,7 @@ class BaseFilesystemModifyTest: self.image.write_file("TEST.XEX", None, data) assert len(self.image.files) == self.num_files_in_sample + 1 - data2 = np.fromstring(self.image.find_file("TEST.XEX"), dtype=np.uint8) + data2 = np.frombuffer(self.image.find_file("TEST.XEX"), dtype=np.uint8) assert np.array_equal(data, data2[0:len(data)]) def test_50k(self):