mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Issue #23753: Python doesn't support anymore platforms without stat() or
fstat(), these functions are always required. Remove HAVE_STAT and HAVE_FSTAT defines, and stop supporting DONT_HAVE_STAT and DONT_HAVE_FSTAT.
This commit is contained in:
parent
551350a79f
commit
f329878e74
7 changed files with 4 additions and 73 deletions
|
@ -519,17 +519,8 @@ Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
|
|||
#endif /* __APPLE__ */
|
||||
}
|
||||
|
||||
/* In principle, this should use HAVE__WSTAT, and _wstat
|
||||
should be detected by autoconf. However, no current
|
||||
POSIX system provides that function, so testing for
|
||||
it is pointless.
|
||||
Not sure whether the MS_WINDOWS guards are necessary:
|
||||
perhaps for cygwin/mingw builds?
|
||||
*/
|
||||
#if defined(HAVE_STAT) && !defined(MS_WINDOWS)
|
||||
|
||||
/* Get file status. Encode the path to the locale encoding. */
|
||||
|
||||
int
|
||||
_Py_wstat(const wchar_t* path, struct stat *buf)
|
||||
{
|
||||
|
@ -544,11 +535,8 @@ _Py_wstat(const wchar_t* path, struct stat *buf)
|
|||
PyMem_Free(fname);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_FSTAT) || defined(MS_WINDOWS)
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */
|
||||
|
||||
|
@ -679,10 +667,8 @@ _Py_fstat(int fd, struct _Py_stat_struct *result)
|
|||
return fstat(fd, result);
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_FSTAT || MS_WINDOWS */
|
||||
|
||||
|
||||
#ifdef HAVE_STAT
|
||||
/* Call _wstat() on Windows, or encode the path to the filesystem encoding and
|
||||
call stat() otherwise. Only fill st_mode attribute on Windows.
|
||||
|
||||
|
@ -715,8 +701,6 @@ _Py_stat(PyObject *path, struct stat *statbuf)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_STAT */
|
||||
|
||||
|
||||
static int
|
||||
get_inheritable(int fd, int raise)
|
||||
|
|
|
@ -1481,7 +1481,6 @@ PyMarshal_ReadLongFromFile(FILE *fp)
|
|||
return res;
|
||||
}
|
||||
|
||||
#if defined(HAVE_FSTAT) || defined(MS_WINDOWS)
|
||||
/* Return size of file in bytes; < 0 if unknown or INT_MAX if too big */
|
||||
static off_t
|
||||
getfilesize(FILE *fp)
|
||||
|
@ -1496,7 +1495,6 @@ getfilesize(FILE *fp)
|
|||
else
|
||||
return (off_t)st.st_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we can get the size of the file up-front, and it's reasonably small,
|
||||
* read it in one gulp and delegate to ...FromString() instead. Much quicker
|
||||
|
@ -1509,7 +1507,6 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
|
|||
{
|
||||
/* REASONABLE_FILE_LIMIT is by defn something big enough for Tkinter.pyc. */
|
||||
#define REASONABLE_FILE_LIMIT (1L << 18)
|
||||
#if defined(HAVE_FSTAT) || defined(MS_WINDOWS)
|
||||
off_t filesize;
|
||||
filesize = getfilesize(fp);
|
||||
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
|
||||
|
@ -1522,7 +1519,6 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
/* We don't have fstat, or we do but the file is larger than
|
||||
* REASONABLE_FILE_LIMIT or malloc failed -- read a byte at a time.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue