@@ -1236,6 +1236,7 @@ _Py_fstat_noraise(int fd, struct _Py_stat_struct *status)
1236
1236
BY_HANDLE_FILE_INFORMATION info ;
1237
1237
FILE_BASIC_INFO basicInfo ;
1238
1238
FILE_ID_INFO idInfo ;
1239
+ FILE_ID_INFO * pIdInfo = & idInfo ;
1239
1240
HANDLE h ;
1240
1241
int type ;
1241
1242
@@ -1268,15 +1269,19 @@ _Py_fstat_noraise(int fd, struct _Py_stat_struct *status)
1268
1269
}
1269
1270
1270
1271
if (!GetFileInformationByHandle (h , & info ) ||
1271
- !GetFileInformationByHandleEx (h , FileBasicInfo , & basicInfo , sizeof (basicInfo )) ||
1272
- !GetFileInformationByHandleEx (h , FileIdInfo , & idInfo , sizeof (idInfo ))) {
1272
+ !GetFileInformationByHandleEx (h , FileBasicInfo , & basicInfo , sizeof (basicInfo ))) {
1273
1273
/* The Win32 error is already set, but we also set errno for
1274
1274
callers who expect it */
1275
1275
errno = winerror_to_errno (GetLastError ());
1276
1276
return -1 ;
1277
1277
}
1278
1278
1279
- _Py_attribute_data_to_stat (& info , 0 , & basicInfo , & idInfo , status );
1279
+ if (!GetFileInformationByHandleEx (h , FileIdInfo , & idInfo , sizeof (idInfo ))) {
1280
+ /* Failed to get FileIdInfo, so do not pass it along */
1281
+ pIdInfo = NULL ;
1282
+ }
1283
+
1284
+ _Py_attribute_data_to_stat (& info , 0 , & basicInfo , pIdInfo , status );
1280
1285
return 0 ;
1281
1286
#else
1282
1287
return fstat (fd , status );
0 commit comments