[Python-checkins] commit of r41662 - in python/trunk: Misc/NEWS Objects/fileobject.c configure configure.in pyconfig.h.in
Guido van Rossum
guido at python.org
Tue Dec 13 19:57:55 CET 2005
Isn't it expensive to call isatty() on every tell() call? Is it worth
it just to make a unit test pass?
Or is there a real bug caused by tell() lying?
--Guido
On 12/13/05, hyeshik.chang <python-checkins at python.org> wrote:
> Author: hyeshik.chang
> Date: Tue Dec 13 17:44:02 2005
> New Revision: 41662
>
> Modified:
> python/trunk/Misc/NEWS
> python/trunk/Objects/fileobject.c
> python/trunk/configure
> python/trunk/configure.in
> python/trunk/pyconfig.h.in
> Log:
> Add a workaround for file.ftell() to raise IOError for ttys.
> ftell(3) on BSD doesn't set errno even for ttys and returns useless
> values.
>
>
> Modified: python/trunk/Misc/NEWS
> ==============================================================================
> --- python/trunk/Misc/NEWS (original)
> +++ python/trunk/Misc/NEWS Tue Dec 13 17:44:02 2005
> @@ -12,6 +12,9 @@
> Core and builtins
> -----------------
>
> +- Added a workaround for file.tell() to raise IOError when the file
> + is a tty on every platforms as documented in our library reference.
> +
> - Patch #1350409: Work around signal handling bug in Visual Studio 2005.
>
> - Bug #1281408: Py_BuildValue now works correct even with unsigned longs
>
> Modified: python/trunk/Objects/fileobject.c
> ==============================================================================
> --- python/trunk/Objects/fileobject.c (original)
> +++ python/trunk/Objects/fileobject.c Tue Dec 13 17:44:02 2005
> @@ -482,6 +482,13 @@
> static Py_off_t
> _portable_ftell(FILE* fp)
> {
> +#ifdef HAVE_BROKEN_FTELL
> + /* ftell doesn't fail for tty fds on FreeBSD and some others */
> + if (isatty(fileno(fp))) {
> + errno = ESPIPE;
> + return -1;
> + }
> +#endif
> #if !defined(HAVE_LARGEFILE_SUPPORT)
> return ftell(fp);
> #elif defined(HAVE_FTELLO) && SIZEOF_OFF_T >= 8
>
> Modified: python/trunk/configure
[...]
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-checkins
mailing list