Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

os.stat returns incorrect a/c/mtime for files without permissions under Windows in Python 3.12 #111877

Closed
Labels
3.12only security fixesOS-windowstype-bugAn unexpected behavior, bug, or error
@kfrydel

Description

@kfrydel

Bug report

Bug description:

We are switching our product to Python 3.12 from Python 3.11.2 and our tests caught a difference in the wayos.stat works under Windows. It returns negative values ofst_atime,st_mtime, andst_ctime if there are no permissions assigned to the file.

How to reproduce: you can remove all permissions using Windows Explorer, right-click on a file, select "Properties", select "Security" tab, press "Edit" button, and finally remove all entries from the "Group and user names" list. Or remove all inherited permissions in "Properties / Security /Advanced" window,icacls should show an empty list of permissions, for example:

PS C:\...> icacls a.txta.txtSuccessfully processed 1 files; Failed processing 0 files

and then check the output in Python 3.12:

(python-312)PSC:\...>python-c"import os; print(os.stat('a.txt'))"os.stat_result(st_mode=33206,st_ino=0,st_dev=0,st_nlink=0,st_uid=0,st_gid=0,st_size=0,st_atime=-11644473600,st_mtime=-11644473600,st_ctime=-11644473600)

and the same for Python 3.11.2, which is correct:

(python-311)PSC:\...>python-c"import os; print(os.stat('a.txt'))"os.stat_result(st_mode=33206,st_ino=0,st_dev=0,st_nlink=0,st_uid=0,st_gid=0,st_size=0,st_atime=1699527432,st_mtime=1699527008,st_ctime=1699527008)

The returned value sounds likesecs_between_epochs fromhttps://github.com/python/cpython/blob/main/Python/fileutils.c#L1050 Maybe it has something to do with the issue.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesOS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp