规范报错
This commit is contained in:
parent
c8af031c83
commit
13047c2443
10
Memory.py
10
Memory.py
|
@ -12,15 +12,15 @@ class Memory:
|
|||
|
||||
def __getitem__(self, key: int):
|
||||
if key > self.size:
|
||||
raise AddressError
|
||||
raise AddressError(key)
|
||||
return self.data[key]
|
||||
|
||||
def write(self, index: int, val: int):
|
||||
if index > self.size:
|
||||
raise AddressError()
|
||||
raise AddressError(index)
|
||||
self.data[index] = val
|
||||
|
||||
def write_batch(self, start, dt: list[int]):
|
||||
def write_batch(self, start, dt):
|
||||
if start + len(dt) > self.size:
|
||||
raise OutOfMemory("内存用尽")
|
||||
|
||||
|
@ -46,12 +46,12 @@ class Memory:
|
|||
stop = k.stop
|
||||
|
||||
if start > self.size or stop > self.size:
|
||||
raise AddressError
|
||||
raise AddressError(start)
|
||||
|
||||
self.data[start:stop] = v
|
||||
return
|
||||
|
||||
if k > self.size:
|
||||
raise AddressError
|
||||
raise AddressError(k)
|
||||
self.data[k] = v
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user