This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年04月27日 21:00 by Arfrever, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue11941.patch | rosslagerwall, 2011年06月03日 19:20 | patch + doc for issue | review | |
| issue11941_2.patch | rosslagerwall, 2011年06月08日 05:11 | version 2 | review | |
| Messages (9) | |||
|---|---|---|---|
| msg134616 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2011年04月27日 21:00 | |
I would like to suggest to add st_atim, st_mtim and st_ctim attributes in os.stat_result objects returned by os.stat(). These attributes would be 2-tuples containing number of seconds and number of nanoseconds. They would expose relevant functionality from libc's stat() and provide better precision than floating-point-based st_atime, st_mtime and st_ctime attributes. st_atim, st_mtim and st_ctim attributes would be available only if Python has been built on system with libc supporting st_atim, st_mtim and st_ctim in stat structure. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html |
|||
| msg134643 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年04月28日 04:47 | |
I think this is a duplicate of #11457. |
|||
| msg134679 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2011年04月28日 14:34 | |
Actually issue #11941 should be a dependency of issue #11457. Issue #11941 is only about os.stat(), while issue #11457 proposes changes also in other places (e.g. tarfile module). |
|||
| msg134691 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年04月28日 16:14 | |
Ok, that's true, reopening. |
|||
| msg137573 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年06月03日 19:20 | |
Attached is a patch for review. It adds st_atim, st_ctim and st_mtim. They are defined even when the underlying system does not have nanosecond precision. |
|||
| msg137577 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2011年06月03日 19:54 | |
st_atim, st_mtim and st_ctim were introduced in 2008 version of POSIX (and were earlier provided by glibc as an extension). To avoid compilation failure with some exotic versions of libc, I suggest: - In configure.in: AC_CHECK_MEMBERS([struct stat.st_atim]) AC_CHECK_MEMBERS([struct stat.st_ctim]) AC_CHECK_MEMBERS([struct stat.st_mtim]) - In Modules/posixmodule.c: PyObject *atim = Py_BuildValue(_STAT_FMT, st->st_atime, #ifdef HAVE_STRUCT_STAT_ST_ATIM st->st_atim.tv_nsec #else 0 #endif ); ... |
|||
| msg137896 - (view) | Author: Ross Lagerwall (rosslagerwall) (Python committer) | Date: 2011年06月08日 05:11 | |
Here is an updated patch that uses the atim, ctim and mtim variables (which are assigned based on various #ifdefs). This should now work on Linux, BSD and Windows. |
|||
| msg137900 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年06月08日 11:46 | |
I'm not sure if that's deliberate, but the new attributes don't appear in the result repr():
>>> s = os.stat("LICENSE")
>>> s
posix.stat_result(st_mode=33204, st_ino=524885, st_dev=2053, st_nlink=1, st_uid=500, st_gid=500, st_size=14597, st_atime=1307474138, st_mtime=1299630588, st_ctime=1299630588)
>>> s.st_mtim
(1299630588, 90781883)
In the docs, you also need a "versionchanged" tag to mention that the attributes were added in 3.3.
The patch fails to compile under Windows: MSVC forbids variable declarations after code (atim, ctim, mtim), you have to put them at the beginning of a block. Once this is fixed, it seems to work ok.
|
|||
| msg154404 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年02月26日 22:01 | |
Given Guido's rejection of PEP 410, this won't happen, so I'm closing this bug. Our BFDL has specifically rejected any of the complicated representations; he ruled that all we need are new _ns fields representing the time in nanoseconds, and to accept a "ns=" argument for os.utime and its ilk. Please see bug #14127 for discussion of that change. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:16 | admin | set | github: 56150 |
| 2012年02月26日 22:01:36 | larry | set | status: open -> closed nosy: + larry messages: + msg154404 resolution: wont fix |
| 2011年06月08日 11:46:43 | pitrou | set | nosy:
+ pitrou messages: + msg137900 |
| 2011年06月08日 05:11:35 | rosslagerwall | set | files:
+ issue11941_2.patch messages: + msg137896 |
| 2011年06月03日 19:54:20 | Arfrever | set | messages: + msg137577 |
| 2011年06月03日 19:20:42 | rosslagerwall | set | files:
+ issue11941.patch keywords: + patch messages: + msg137573 stage: patch review |
| 2011年06月03日 17:03:51 | r.david.murray | set | nosy:
+ r.david.murray |
| 2011年04月28日 16:15:49 | rosslagerwall | link | issue11457 dependencies |
| 2011年04月28日 16:14:59 | rosslagerwall | set | status: closed -> open resolution: duplicate -> (no value) messages: + msg134691 |
| 2011年04月28日 14:34:21 | Arfrever | set | messages: + msg134679 |
| 2011年04月28日 04:47:27 | rosslagerwall | set | status: open -> closed nosy: + rosslagerwall messages: + msg134643 resolution: duplicate |
| 2011年04月27日 21:00:15 | Arfrever | create | |