mirror of
https://github.com/python/cpython.git
synced 2025-09-11 11:17:16 +00:00
SF bug #951915: fix bug in StringIO.truncate - length not changed
(Patch by Armin Rigo.)
This commit is contained in:
parent
2ccea17856
commit
6065d32325
2 changed files with 9 additions and 0 deletions
|
@ -204,6 +204,7 @@ class StringIO:
|
||||||
elif size < self.pos:
|
elif size < self.pos:
|
||||||
self.pos = size
|
self.pos = size
|
||||||
self.buf = self.getvalue()[:size]
|
self.buf = self.getvalue()[:size]
|
||||||
|
self.len = size
|
||||||
|
|
||||||
def write(self, s):
|
def write(self, s):
|
||||||
"""Write a string to the file.
|
"""Write a string to the file.
|
||||||
|
@ -312,6 +313,11 @@ def test():
|
||||||
print 'File length =', f.tell()
|
print 'File length =', f.tell()
|
||||||
if f.tell() != length:
|
if f.tell() != length:
|
||||||
raise RuntimeError, 'bad length'
|
raise RuntimeError, 'bad length'
|
||||||
|
f.truncate(length/2)
|
||||||
|
f.seek(0, 2)
|
||||||
|
print 'Truncated length =', f.tell()
|
||||||
|
if f.tell() != length/2:
|
||||||
|
raise RuntimeError, 'truncate did not adjust length'
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -30,6 +30,9 @@ Extension Modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- StringIO.truncate() now correctly adjusts the size attribute.
|
||||||
|
(Bug #951915).
|
||||||
|
|
||||||
- locale.py now uses an updated locale alias table (built using
|
- locale.py now uses an updated locale alias table (built using
|
||||||
Tools/i18n/makelocalealias.py, a tool to parse the X11 locale
|
Tools/i18n/makelocalealias.py, a tool to parse the X11 locale
|
||||||
alias file); the encoding lookup was enhanced to use Python's
|
alias file); the encoding lookup was enhanced to use Python's
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue