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