diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2005-12-13 16:44:02 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2005-12-13 16:44:02 (GMT) |
commit | e237d50390433a4d38944221a6c3280cc6940d9e (patch) | |
tree | 326e24476a76c251bbcbbd8c3acc18d5f2d07adf /Objects/fileobject.c | |
parent | 50f8169fb6520488c6b4dfcb4603e845d5ae1ca1 (diff) | |
download | cpython-e237d50390433a4d38944221a6c3280cc6940d9e.zip cpython-e237d50390433a4d38944221a6c3280cc6940d9e.tar.gz cpython-e237d50390433a4d38944221a6c3280cc6940d9e.tar.bz2 |
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.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 259a423..1de520b 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -482,6 +482,13 @@ _portable_fseek(FILE *fp, Py_off_t offset, int whence) 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 |