[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Comments on the patch: - you should check the error return of lseek() (and possibly wrap it in Py_BEGIN/END_ALLOW_THREADS, see portable_lseek() in the same file) - there should be a test for each of unbuffered IO (buffering=0), buffered IO (rb)

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch version 2: - raise raise PyErr_SetFromErrno(PyExc_IOError) on lseek() error - add tests for unbuffered binary file and (buffered) text file I use the type long to store the lseek() result, because I don't know if off_t is

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I use the type long to store the lseek() result, because I don't know if off_t is available on all OS. Py_off_t may be used, but it's defined above (after fileio_init). Instead of checking the return type, you can first set errno to 0, and

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Last thing, in your patch there is a forward declaration to portable_lseek but it doesn't look used anywhere... ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5008

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: New try (version 3): - reuse Py_off_t in fileio_init() instead of long - use Python coding style: f.tell() 0 - remove the unused forward declaration of portable_lseek() This patch also prepares a fix for #5016. Added file:

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file12804/fileio_append.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5008 ___

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Version 4: ok, let's use *portable*_lseek() instead of the ugly lseek() function (not compatible with large files on Windows). Added file: http://bugs.python.org/file12820/fileio_append-4.patch

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-20 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- resolution: - accepted ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5008 ___ ___ Python-bugs-list

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-19 Thread STINNER Victor
New submission from STINNER Victor victor.stin...@haypocalc.com: The following code must display 3 instead of 0: --- with open(x, w) as f: f.write(xxx) with open(x, a) as f: print(f.tell()) --- The example works with Python 2.x, because file object is implemented using the FILE

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-19 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- priority: - release blocker type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5008 ___

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-19 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch _including a test_: + if (append) + lseek(self-fd, 0, SEEK_END); -- keywords: +patch Added file: http://bugs.python.org/file12803/fileio_append.patch ___ Python

[issue5008] Wrong tell() result for a file opened in append mode

2009-01-19 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file12803/fileio_append.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5008 ___