Terry J. Reedy <tjre...@udel.edu> added the comment: "Enhancements" (non-bugfix feature changes) can only be applied to future versions. However, you are asking for the reversion of an intentional feature change made in a 'bugfix' release# for (I believe) 3.1. Before the change, as I remember, truncating to 0 *did* move the file pointer back to 0. As I remember, Guide von Rossum requested the change and Antoine Pitrou made it.
https://docs.python.org/3/library/io.html#io.IOBase.seek new says "The current stream position isn’t changed." If you also want to change the stream position, do it with seek(), perhaps before the truncate. # This change in a bugfix release, a violation the rule stated above, broke the code of multiple people. (We thereafter strengthened the policy.) To fix my code, I had to add a seek(0). I put it before truncate(0), so I know that this works. ---------- nosy: +terry.reedy resolution: -> rejected stage: -> resolved status: open -> closed title: [issue] io's r+ mode truncate(0) -> io's r+ mode truncate(0) versions: +Python 3.10 -Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42733> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com