Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue1323] py3k: file.truncate() changes the file position

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Oct 24, 2007, 3:30 PM

Post #1 of 3 (110 views)
Permalink
[issue1323] py3k: file.truncate() changes the file position

New submission from Amaury Forgeot d'Arc:

This patch corrects a problem in test_file.py on Windows:
f.truncate() seeks to the truncation point, but does not empty the
buffers. In the test, f.tell() returns -1...

Now we flush the file before, and seek to the initial position after.
The same trick was present in 2.5, in fileobject.c::file_truncate. The
same comments apply as well.

Reviewers needed! Flushing may change the behaviour, but seems more
correct to me (and closer to python2.5). Should we add specific tests
for this?

Also, change the test to be sure to close the file before trying to
remove it (it seems that in a finally: block, the exception still
references all the local variables in the traceback). Otherwise the
previous problem is hidden by a "file locked" error in the finally block.

----------
components: Windows
files: truncate.diff
messages: 56732
nosy: amaury.forgeotdarc
severity: normal
status: open
title: py3k: file.truncate() changes the file position
versions: Python 3.0
Added file: http://bugs.python.org/file8606/truncate.diff

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1323>
__________________________________
Attachments: truncate.diff (2.06 KB)


report at bugs

Oct 24, 2007, 8:44 PM

Post #2 of 3 (104 views)
Permalink
[issue1323] py3k: file.truncate() changes the file position [In reply to]

Changes by Martin v. Löwis:


----------
keywords: +patch

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1323>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 25, 2007, 4:23 PM

Post #3 of 3 (97 views)
Permalink
[issue1323] py3k: file.truncate() changes the file position [In reply to]

Guido van Rossum added the comment:

Looks fine to me.
Committed revision 58658.

----------
nosy: +gvanrossum
resolution: -> accepted
status: open -> closed

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1323>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.