bpo-29619: Convert st_ino using unsigned integer (#557) (#584) · python/cpython@68d2980

@@ -1932,11 +1932,13 @@ _pystat_fromstructstat(STRUCT_STAT *st)

19321932

return NULL;

1933193319341934

PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));

1935-

#ifdef HAVE_LARGEFILE_SUPPORT

1935+

#if defined(HAVE_LARGEFILE_SUPPORT) || defined(MS_WINDOWS)

1936+

Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(st->st_ino));

19361937

PyStructSequence_SET_ITEM(v, 1,

1937-

PyLong_FromLongLong((long long)st->st_ino));

1938+

PyLong_FromUnsignedLongLong(st->st_ino));

19381939

#else

1939-

PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino));

1940+

Py_BUILD_ASSERT(sizeof(unsigned long) >= sizeof(st->st_ino));

1941+

PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLong(st->st_ino));

19401942

#endif

19411943

#ifdef MS_WINDOWS

19421944

PyStructSequence_SET_ITEM(v, 2, PyLong_FromUnsignedLong(st->st_dev));

@@ -11156,7 +11158,7 @@ typedef struct {

1115611158

PyObject *lstat;

1115711159

#ifdef MS_WINDOWS

1115811160

struct _Py_stat_struct win32_lstat;

11159-

__int64 win32_file_index;

11161+

uint64_t win32_file_index;

1116011162

int got_file_index;

1116111163

#else /* POSIX */

1116211164

#ifdef HAVE_DIRENT_D_TYPE

@@ -11419,7 +11421,8 @@ DirEntry_inode(DirEntry *self)

1141911421

self->win32_file_index = stat.st_ino;

1142011422

self->got_file_index = 1;

1142111423

}

11422-

return PyLong_FromLongLong((long long)self->win32_file_index);

11424+

Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(self->win32_file_index));

11425+

return PyLong_FromUnsignedLongLong(self->win32_file_index);

1142311426

#else /* POSIX */

1142411427

#ifdef HAVE_LARGEFILE_SUPPORT

1142511428

return PyLong_FromLongLong((long long)self->d_ino);