diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-03-09 16:34:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 16:34:28 (GMT) |
commit | 0f6d73343d342c106cda2219ebb8a6f0c4bd9b3c (patch) | |
tree | 1d79b8e053f15f5f55a9941a057ba23d42be0c0d /Modules/posixmodule.c | |
parent | feccdb2a249a71be330765be77dee57121866779 (diff) | |
download | cpython-0f6d73343d342c106cda2219ebb8a6f0c4bd9b3c.zip cpython-0f6d73343d342c106cda2219ebb8a6f0c4bd9b3c.tar.gz cpython-0f6d73343d342c106cda2219ebb8a6f0c4bd9b3c.tar.bz2 |
bpo-29619: Convert st_ino using unsigned integer (#557)
bpo-29619: os.stat() and os.DirEntry.inodeo() now convert inode
(st_ino) using unsigned integers.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index ae03d06..0ae06eb 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1927,11 +1927,13 @@ _pystat_fromstructstat(STRUCT_STAT *st) return NULL; PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode)); -#ifdef HAVE_LARGEFILE_SUPPORT +#if defined(HAVE_LARGEFILE_SUPPORT) || defined(MS_WINDOWS) + Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(st->st_ino)); PyStructSequence_SET_ITEM(v, 1, - PyLong_FromLongLong((long long)st->st_ino)); + PyLong_FromUnsignedLongLong(st->st_ino)); #else - PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); + Py_BUILD_ASSERT(sizeof(unsigned long) >= sizeof(st->st_ino)); + PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLong(st->st_ino)); #endif #ifdef MS_WINDOWS PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev)); @@ -11152,7 +11154,7 @@ typedef struct { PyObject *lstat; #ifdef MS_WINDOWS struct _Py_stat_struct win32_lstat; - __int64 win32_file_index; + uint64_t win32_file_index; int got_file_index; #else /* POSIX */ #ifdef HAVE_DIRENT_D_TYPE @@ -11409,7 +11411,8 @@ os_DirEntry_inode_impl(DirEntry *self) self->win32_file_index = stat.st_ino; self->got_file_index = 1; } - return PyLong_FromLongLong((long long)self->win32_file_index); + 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); |