Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scandir direntry.stat() always returns st_ctime of 0 on Windows #117267

Closed
ppixiv opened this issue Mar 26, 2024 · 0 comments
Closed

scandir direntry.stat() always returns st_ctime of 0 on Windows #117267

ppixiv opened this issue Mar 26, 2024 · 0 comments
Assignees
Labels
3.12 bugs and security fixes 3.13 new features, bugs and security fixes OS-windows type-bug An unexpected behavior, bug, or error

Comments

@ppixiv
Copy link

ppixiv commented Mar 26, 2024

Bug report

Bug description:

In 3.12 on Windows, calling stat() on a direntry returned from os.scandir() always returns an st_ctime of 0:

import os
for direntry in os.scandir('.'):
    st = direntry.stat()
    print(st.st_ctime)

In 3.10, this gave reasonable timestamps. In 3.12, it's always 0. This only affects os.scandir, not os.stat. I'm guessing it's related to this (https://docs.python.org/3/whatsnew/3.12.html#deprecated):

"The st_ctime fields return by os.stat() and os.lstat() on Windows are deprecated. In a future release, they will contain the last metadata change time, consistent with other platforms. For now, they still contain the creation time, which is also available in the new st_birthtime field. (Contributed by Steve Dower in gh-99726.)"

The os.stat results are as described, but maybe direntry.stat() was overlooked. I think it should also give st_ctime = st_birthtime for the compatibility period, like os.stat() is doing, not 0.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

@ppixiv ppixiv added the type-bug An unexpected behavior, bug, or error label Mar 26, 2024
@zooba zooba added 3.12 bugs and security fixes 3.13 new features, bugs and security fixes labels Mar 26, 2024
@zooba zooba self-assigned this Mar 28, 2024
zooba added a commit to zooba/cpython that referenced this issue Mar 28, 2024
zooba added a commit that referenced this issue Apr 3, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 3, 2024
…ion time during deprecation period (pythonGH-117354)

(cherry picked from commit 985917d)

Co-authored-by: Steve Dower <steve.dower@python.org>
zooba added a commit that referenced this issue Apr 3, 2024
…me during deprecation period (GH-117354)

(cherry picked from commit 985917d)

Co-authored-by: Steve Dower <steve.dower@python.org>
@zooba zooba closed this as completed Apr 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 new features, bugs and security fixes OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants