GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — scandir direntry.stat() always returns st_ctime of 0 on Windows · Issue #117267 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
scandir direntry.stat() always returns st_ctime of 0 on Windows#117267
Copy link
Assignees
zooba
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesOS-windowstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@ppixiv
ppixiv
opened on Mar 26, 2024
Issue body actions

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

  • gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period #117354
  • [3.12] gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (GH-117354) #117525

Activity

  1. ppixiv
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 26, 2024
  2. ronaldoussoren
    added
    OS-windows
    on Mar 26, 2024
  3. zooba
    added
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    on Mar 26, 2024
  4. zooba
    self-assigned this
    on Mar 28, 2024
  5. zooba
    added 2 commits that reference this issue on Mar 28, 2024

    pythongh-117267: Ensure DirEntry.stat().st_ctime still contains creat…

    20a73fb

    gh-117267: Ensure DirEntry.stat().st_ctime still contains creation ti…

    985917d
  6. miss-islington
    added a commit that references this issue on Apr 3, 2024

    pythongh-117267: Ensure DirEntry.stat().st_ctime still contains creat…

    b7becac
  7. zooba
    added a commit that references this issue on Apr 3, 2024

    gh-117267: Ensure DirEntry.stat().st_ctime still contains creation ti…

    eca377f
  8. zooba
    closed this as completedon Apr 4, 2024
  9. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythongh-117267: Ensure DirEntry.stat().st_ctime still contains creat…

    3fd4260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @zooba
    zooba

Labels

3.12only security fixesonly security fixes3.13only security fixesonly security fixesOS-windowstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.