[issue16273] f.tell() returning negative number on Windows build

2013-07-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 81bc2d64c006 by R David Murray in branch '3.3':
#16273: Fix tutorial discussion of seek/tell (opaque text-mode values).
http://hg.python.org/cpython/rev/81bc2d64c006

New changeset c7d9a2159c6c by R David Murray in branch 'default':
Merge: #16273: Fix tutorial discussion of seek/tell (opaque text-mode values).
http://hg.python.org/cpython/rev/c7d9a2159c6c

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-13 Thread Sijin Joseph

Sijin Joseph added the comment:

Attaching a patch with a doc update to the tutorial, specifying that

1. The return value from f.tell is an opaque number for text files.
2. When seeking using text files the offset value needs to come from f.tell(). 
http://docs.python.org/3.4/library/io.html#io.TextIOBase.seek

--
keywords: +patch
nosy: +sijinjoseph
Added file: http://bugs.python.org/file29823/16273-doc-update.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-13 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
assignee:  - docs@python
components: +Documentation, IO -Interpreter Core
nosy: +docs@python
priority: high - normal
stage: test needed - patch review
versions: +Python 3.3, Python 3.4 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-13 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


--
nosy:  -arigo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Giacomo, which behaviour are you talking about?
FWIW, there is no such tell() issue in Python 3 and it doesn't use ftell().

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-11 Thread Giacomo Alzetta

Giacomo Alzetta added the comment:

I can reproduce a similar behaviour, but instead of negative values I obtain 
huge values(which may as well be a negative unsigned converted to a python 
int).

See this stackoverflow question: 
http://stackoverflow.com/questions/15934950/python-file-tell-giving-strange-numbers

If it doesn't use ftell() then this might mean that there is a new bug in the 
current implementation? I can reproduce the results of the questioner, on a 
windows7 machine with python3.3.0, with the following code:

with open('C:/Users/Giacomo/test', 'wb') as f:
f.write(b'hello\r\n\r\n-data1:blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah\r\n\r\n\r\n-data2:blah blah blah blah 
blah blah blah blah blah blah blah\r\n-data3: Empty\r\n\r\n-data4: Empty')
with open('C:/Users/Giacomo/test', 'rt') as f:
for line in iter(f.readline, ''):
print(f.tell())

Which outputs:

7
9
18446744073709551714
99
101
164
179
181
194

As I explained in my answer I thought the 1844... was due to the ftell() bug, 
but if that's not it I'm at a loss. Could you explain this results with the 
current implementation?

By the way: it seems to be a python3.3 bug, since python3.2.3 is not affected.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-11 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Giacomo, that's not related to the 2.7 problem. In Python 3, the result of 
f.tell() is not a file position, but a special value that tells the decoder to 
pick up when you seek().

--
nosy: +benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-11 Thread Giacomo Alzetta

Giacomo Alzetta added the comment:

The documentation for python 3.3.1 states, at 
http://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files, 
states:

f.tell() returns an integer giving the file object’s current position in 
the file, **measured in bytes from the beginning of the file**.

And regarding files opened in text mode the only statement is:

In text files (those opened without a b in the mode string), only seeks 
relative to the beginning of the file are allowed (the exception being seeking 
to the very file end with seek(0, 2)).

Even though in the io module it is documented that it may not be the number of 
bytes.

I think the former documentation should be changed, since it's simply wrong. 
Sorry for the disturb, but in the beginning I thought it was related.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-11 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy:  -brian.curtin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-04-10 Thread Giacomo Alzetta

Giacomo Alzetta added the comment:

I can't find any mention of this behaviour in python3's documentation, nor any 
reference to ftell(). Is it only well hidden or was it deleted by accident?

--
nosy: +bakuriu
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-03-28 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
resolution:  - wont fix
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-20 Thread Catalin Iacob

Catalin Iacob added the comment:

Could it be that Raymond's file had Unix line endings?

I tried to reproduce this, picked a file on my disk and indeed I got a negative 
number, but that file has Unix line endings. This is documented at 
http://docs.python.org/2/library/stdtypes.html#file.tell so probably there's 
nothing to do then.

As for Armin's report in msg180145, even though it's not intuitive, this 
matches ftell's behavior on Windows, as documented in the Remarks section of 
http://msdn.microsoft.com/en-us/library/0ys3hc0b%28v=vs.100%29.aspx. The tell() 
method on fileobjects is explicitly documented as matching ftell behavior: 
Return the file’s current position, like stdio‘s ftell(). So even though it's 
not intuitive at all, it's probably better to leave it as is. tell() returns 
the intuitive non zero position when opening with 'a' on Python3 and on Python 
2.7 when using io.open so it's fixed for the future anyway.

--
nosy: +catalin.iacob

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-19 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy: +brian.curtin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-17 Thread Armin Rigo

Armin Rigo added the comment:

FWIW, on Windows only, open('foo', 'a').tell() always returns 0, which I 
think is broken too.  It usually works anyway, because it updates the position 
before the first .write().  But it does not work in case the writing occurs in 
another process, like described here:

http://stackoverflow.com/questions/13821708/

(Tested only on Python 2.6.2, but according to the link above, Python 2.7.3 has 
the same problem.)

--
nosy: +arigo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-17 Thread Stefan Krah

Stefan Krah added the comment:

What is in sample.txt? I cannot reproduce this with a source build
(Windows 7, 64-bit pgo build):

Python 2.7.3+ (default, Jan 17 2013, 20:26:24) [MSC v.1500 64 bit (AMD64)] on 
win32  
Type help, copyright, credits or license for more information.  
 
 f = open('sample.txt')  
  
 f.read(3)   
  
'abc'   
 
 f.read(3)   
  
'def'   
 
 f.tell()
  
6L

--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I am afraid I cannot reproduce with the 2.7.3 64-bit installer either:

C:\python27\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on 
win32
Type help, copyright, credits or license for more information.
 f = open(sample.txt)
 f.read(3)
'xxx'
 f.read(3)
'xxx'
 f.tell()
6L

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2013-01-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
stage:  - test needed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2012-10-18 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +pitrou
priority: normal - high

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2012-10-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What tell() returns before any reading? What about non-buffered files?

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16273] f.tell() returning negative number on Windows build

2012-10-17 Thread Raymond Hettinger

New submission from Raymond Hettinger:

On a fresh 64-bit install of Windows 2.7.3 running on Windows 7, f.tell() is 
producing unexpected (and unusable) results:

 f = open('sample.txt')
 f.read(3)
 f.read(3)
 f.tell()
-5L

--
components: Interpreter Core
messages: 173226
nosy: rhettinger
priority: normal
severity: normal
status: open
title: f.tell() returning negative number on Windows build
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16273
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com