diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-04-03 22:32:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 22:32:09 (GMT) |
commit | eca377f203c95153f69faf7d435f5e537ad9b59a (patch) | |
tree | 0e15d9e8c902f0caa8b28fc59aa56f7fd3f28419 | |
parent | fad48ea1816be3125ea51edcdfe2f999d6ade796 (diff) | |
download | cpython-eca377f203c95153f69faf7d435f5e537ad9b59a.zip cpython-eca377f203c95153f69faf7d435f5e537ad9b59a.tar.gz cpython-eca377f203c95153f69faf7d435f5e537ad9b59a.tar.bz2 |
gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (GH-117354)
(cherry picked from commit 985917dc8d34e2d2f717f7a981580a8dcf18d53a)
Co-authored-by: Steve Dower <steve.dower@python.org>
-rw-r--r-- | Misc/NEWS.d/next/Windows/2024-03-28-22-12-00.gh-issue-117267.K_tki1.rst | 5 | ||||
-rw-r--r-- | Modules/posixmodule.c | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Windows/2024-03-28-22-12-00.gh-issue-117267.K_tki1.rst b/Misc/NEWS.d/next/Windows/2024-03-28-22-12-00.gh-issue-117267.K_tki1.rst new file mode 100644 index 0000000..d322142 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-03-28-22-12-00.gh-issue-117267.K_tki1.rst @@ -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. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 9f69c79..8fce40b 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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: |