Replaced fromstring with frombuffer (and copy if necessary)
This commit is contained in:
parent
ce66a0c8b0
commit
dafba8e74c
|
@ -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
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue