Skip to content

Commit b7becac

Browse files
zoobamiss-islington
authored andcommitted
pythongh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (pythonGH-117354)
(cherry picked from commit 985917d) Co-authored-by: Steve Dower <[email protected]>
1 parent fad48ea commit b7becac

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Ensure ``DirEntry.stat().st_ctime`` behaves consistently with
2+
:func:`os.stat` during the deprecation period of ``st_ctime`` by containing
3+
the same value as ``st_birthtime``. After the deprecation period,
4+
``st_ctime`` will be the metadata change time (or unavailable through
5+
``DirEntry``), and only ``st_birthtime`` will contain the creation time.

Modules/posixmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15050,6 +15050,10 @@ DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW)
1505015050
find_data_to_file_info(dataW, &file_info, &reparse_tag);
1505115051
_Py_attribute_data_to_stat(&file_info, reparse_tag, NULL, NULL, &entry->win32_lstat);
1505215052

15053+
/* ctime is only deprecated from 3.12, so we copy birthtime across */
15054+
entry->win32_lstat.st_ctime = entry->win32_lstat.st_birthtime;
15055+
entry->win32_lstat.st_ctime_nsec = entry->win32_lstat.st_birthtime_nsec;
15056+
1505315057
return (PyObject *)entry;
1505415058

1505515059
error:

0 commit comments

Comments
 (0)