[issue22651] Open file in a+ mode reads from end of file in Python 3.4

2014-10-16 Thread Nick Jacobson

New submission from Nick Jacobson:

In Python 2.7.8.10 running the following gives one result:

>>> with open(r"C:\myfile.txt", "a+") as f:
... f.tell()
...
0L

But in Python 3.4.1.0 it gives a different result:

>>> with open(r"C:\myfile.txt", "a+") as f:
... f.tell()
...
98

According to the man page for fopen, for a+ mode: "The initial file position 
for reading is at the beginning of the file." Source: 
http://linux.die.net/man/3/fopen

--
components: IO
messages: 229511
nosy: nicksjacobson
priority: normal
severity: normal
status: open
title: Open file in a+ mode reads from end of file in Python 3.4
type: behavior
versions: Python 3.4

___
Python tracker 
<http://bugs.python.org/issue22651>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22651] Open file in a+ mode reads from end of file in Python 3.4

2014-10-16 Thread Nick Jacobson

Nick Jacobson added the comment:

Note: I'm running this in Windows 7, same result on Windows Server 2008.

--

___
Python tracker 
<http://bugs.python.org/issue22651>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22651] Open file in a+ mode reads from end of file in Python 3.4

2014-10-16 Thread Nick Jacobson

Nick Jacobson added the comment:

I also should have mentioned that C:\myfile.txt in my example is 98 bytes long, 
so it is being read from the end instead of the beginning.

--

___
Python tracker 
<http://bugs.python.org/issue22651>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22651] Python 2: Open file in a+ mode on Windows doesn't go to the end

2014-10-16 Thread Nick Jacobson

Nick Jacobson added the comment:

For writing, end of file seems correct. But for reading, the documentation says 
it should be the beginning of the file.

"The initial file position for reading is at the beginning of the file, but 
output is always appended to the end of the file." 
http://linux.die.net/man/3/fopen

--

___
Python tracker 
<http://bugs.python.org/issue22651>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com