mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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.
This commit is contained in:
parent
50f8169fb6
commit
e237d50390
5 changed files with 97 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue