@@ -1864,6 +1864,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
18641864 BY_HANDLE_FILE_INFORMATION fileInfo ;
18651865 FILE_BASIC_INFO basicInfo ;
18661866 FILE_ID_INFO idInfo ;
1867+ FILE_ID_INFO * pIdInfo = & idInfo ;
18671868 FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
18681869 DWORD fileType , error ;
18691870 BOOL isUnhandledTag = FALSE;
@@ -2000,9 +2001,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
20002001
20012002 if (!GetFileInformationByHandle (hFile , & fileInfo ) ||
20022003 !GetFileInformationByHandleEx (hFile , FileBasicInfo ,
2003- & basicInfo , sizeof (basicInfo )) ||
2004- !GetFileInformationByHandleEx (hFile , FileIdInfo ,
2005- & idInfo , sizeof (idInfo ))) {
2004+ & basicInfo , sizeof (basicInfo ))) {
20062005 switch (GetLastError ()) {
20072006 case ERROR_INVALID_PARAMETER :
20082007 case ERROR_INVALID_FUNCTION :
@@ -2018,7 +2017,12 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
20182017 }
20192018 }
20202019
2021- _Py_attribute_data_to_stat (& fileInfo , tagInfo .ReparseTag , & basicInfo , & idInfo , result );
2020+ if (!GetFileInformationByHandleEx (hFile , FileIdInfo , & idInfo , sizeof (idInfo ))) {
2021+ /* Failed to get FileIdInfo, so do not pass it along */
2022+ pIdInfo = NULL ;
2023+ }
2024+
2025+ _Py_attribute_data_to_stat (& fileInfo , tagInfo .ReparseTag , & basicInfo , pIdInfo , result );
20222026 update_st_mode_from_path (path , fileInfo .dwFileAttributes , result );
20232027
20242028cleanup :
0 commit comments