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

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

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Ensure ``DirEntry.stat().st_ctime`` behaves consistently with
:func:`os.stat` during the deprecation period of ``st_ctime`` by containing
the same value as ``st_birthtime``. After the deprecation period,
``st_ctime`` will be the metadata change time (or unavailable through
``DirEntry``), and only ``st_birthtime`` will contain the creation time.
4 changes: 4 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -15050,6 +15050,10 @@ DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW)
find_data_to_file_info(dataW, &file_info, &reparse_tag);
_Py_attribute_data_to_stat(&file_info, reparse_tag, NULL, NULL, &entry->win32_lstat);

/* ctime is only deprecated from 3.12, so we copy birthtime across */
entry->win32_lstat.st_ctime = entry->win32_lstat.st_birthtime;
entry->win32_lstat.st_ctime_nsec = entry->win32_lstat.st_birthtime_nsec;

return (PyObject *)entry;

error:
Expand Down
Loading