This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: StringIO().truncate causes zero-bytes in getvalue()
Type: behavior Stage:
Components: Documentation, IO Versions: Python 3.1
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, hpk, pitrou
Priority: normal Keywords:

Created on 2010-04-28 10:46 by hpk, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit hpk, 2010-04-28 10:46 file containing stringio related assertions
Messages (4)
msg104423 - (view) Author: holger krekel (hpk) Date: 2010-04-28 10:46
Running the attached file with python3.1.1 works fine, all assertions pass.  Running it with 3.1.2 gives me this output: 

$ python3.1.2/bin/python3.1
Traceback (most recent call last):
  File "", line 12, in <module>
    assert s == "world", repr(s)
AssertionError: '\x00\x00\x00\x00\x00world'
msg104424 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-28 10:57
This is a last-minute API change. truncate() was modified not to change the file position anymore. We should probably document it more explicitly.

See the following subthread in python-dev:
msg104425 - (view) Author: holger krekel (hpk) Date: 2010-04-28 11:11
Ah, thanks for the pointer.  So indeed, for me truncate(0)+seek(0)
works fine for all interpreters i care for (python2.4 - 3.1.X),
previously truncate(0) was enough.
msg104457 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-28 20:01
I've updated the doc in r80591. Sorry for the inconvenience!
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52804
2010-04-28 20:01:34pitrousetstatus: open -> closed
resolution: not a bug
messages: + msg104457
2010-04-28 11:11:51hpksetmessages: + msg104425
2010-04-28 10:58:00pitrousetnosy: + docs@python, pitrou
messages: + msg104424

assignee: docs@python
components: + Documentation
2010-04-28 10:46:44hpkcreate