mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #23152: Implement _Py_fstat() to support files larger than 2 GB on Windows.
fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
This commit is contained in:
parent
18d1924987
commit
f2f373f593
12 changed files with 242 additions and 180 deletions
|
|
@ -459,8 +459,8 @@ mmap_size_method(mmap_object *self,
|
|||
|
||||
#ifdef UNIX
|
||||
{
|
||||
struct stat buf;
|
||||
if (-1 == fstat(self->fd, &buf)) {
|
||||
struct _Py_stat_struct buf;
|
||||
if (-1 == _Py_fstat(self->fd, &buf)) {
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1107,7 +1107,7 @@ static PyObject *
|
|||
new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
||||
{
|
||||
#ifdef HAVE_FSTAT
|
||||
struct stat st;
|
||||
struct _Py_stat_struct st;
|
||||
#endif
|
||||
mmap_object *m_obj;
|
||||
PyObject *map_size_obj = NULL;
|
||||
|
|
@ -1174,7 +1174,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
|||
(void)fcntl(fd, F_FULLFSYNC);
|
||||
#endif
|
||||
#ifdef HAVE_FSTAT
|
||||
if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
if (fd != -1 && _Py_fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
if (map_size == 0) {
|
||||
if (st.st_size == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue