[ python-Bugs-1569057 ] Using .next() on file open in write mode writes junk to file

SourceForge.net noreply at sourceforge.net
Mon Oct 2 06:49:37 CEST 2006


Bugs item #1569057, was opened at 2006-10-01 23:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569057&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: andrei kulakov (rainy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Using .next() on file open in write mode writes junk to file

Initial Comment:
When you open a file in write mode and use .next(), it 
prints an error and writes many lines of junk to file. 
I tested on windows and python 2.5:

>>> f = open('test', 'w') 
>>> f.fileno() 
4 
>>> f.write('1\n') 
>>> f.write('2\n3\n4\n') 
>>> f.next() 


Traceback (most recent call last): 
  File "<pyshell#8>", line 1, in <module> 
    f.next() 
IOError: [Errno 9] Bad file descriptor 

>>> f.close() 
>>> f = open('test') 
>>> f.next() 
'1\n' 
>>> f.next() 
'2\n' 
>>> f.next() 
'3\n' 
>>> f.next() 
'4\n' 
>>> f.next() 


'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x00\x­
00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\­
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00 
...many more lines of junk...'



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1569057&group_id=5470


More information about the Python-bugs-list mailing list