Skip to content

bpo-29619: Do not rely on HAVE_LARGEFILE_SUPPORT for the size of type… #1666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1927,14 +1927,8 @@ _pystat_fromstructstat(STRUCT_STAT *st)
return NULL;

PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
#if defined(HAVE_LARGEFILE_SUPPORT) || defined(MS_WINDOWS)
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(st->st_ino));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to see the build assert in the else block.

PEP 7 now requires {...} around if blocks.

PyStructSequence_SET_ITEM(v, 1,
PyLong_FromUnsignedLongLong(st->st_ino));
#else
Py_BUILD_ASSERT(sizeof(unsigned long) >= sizeof(st->st_ino));
PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLong(st->st_ino));
#endif
PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLongLong(st->st_ino));
#ifdef MS_WINDOWS
PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev));
#else
Expand All @@ -1948,12 +1942,8 @@ _pystat_fromstructstat(STRUCT_STAT *st)
PyStructSequence_SET_ITEM(v, 4, _PyLong_FromUid(st->st_uid));
PyStructSequence_SET_ITEM(v, 5, _PyLong_FromGid(st->st_gid));
#endif
#ifdef HAVE_LARGEFILE_SUPPORT
PyStructSequence_SET_ITEM(v, 6,
PyLong_FromLongLong((long long)st->st_size));
#else
PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size));
#endif
Py_BUILD_ASSERT(sizeof(long long) >= sizeof(st->st_size));
PyStructSequence_SET_ITEM(v, 6, PyLong_FromLongLong(st->st_size));

#if defined(HAVE_STAT_TV_NSEC)
ansec = st->st_atim.tv_nsec;
Expand Down Expand Up @@ -11451,11 +11441,8 @@ os_DirEntry_inode_impl(DirEntry *self)
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(self->win32_file_index));
return PyLong_FromUnsignedLongLong(self->win32_file_index);
#else /* POSIX */
#ifdef HAVE_LARGEFILE_SUPPORT
return PyLong_FromLongLong((long long)self->d_ino);
#else
return PyLong_FromLong((long)self->d_ino);
#endif
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(self->d_ino));
return PyLong_FromUnsignedLongLong(self->d_ino);
#endif
}

Expand Down