Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv16976
Modified Files:
bits.py
Log Message:
added some range checking to Bits.__setitem__
Index: bits.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- bits.py 26 Apr 2003 21:27:45 -0000 1.7
+++ bits.py 26 Apr 2003 21:31:19 -0000 1.8
@@ -62,9 +62,14 @@
if index.start == None or index.stop != None or \
not index.step in (1, 2, 4):
raise 'Bad slice for Bits.__setitem__', index
+ if index.start > len(this._contents):
+ raise IndexError, index.start
if index.step == 1: this._contents[index.start] = chr(value % 0x100)
else:
tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step]
this._contents[index.start : index.start + index.step] = \
array('c', pack(tpl, value % (1L << (index.step << 3))))
- else: this._contents[index] = chr(value % 0x100)
+ else:
+ if index > len(this._contents):
+ raise IndexError, index
+ this._contents[index] = chr(value % 0x100)
|