Issue 15228: os.utime() docs not clear on behavior on nonexistant files (original) (raw)

Issue15228

Created on 2012-06-30 19:55 by dewin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue15228-utime-touch-doc.patch bbrazil,2012-07-07 16:17 review
Messages (4)
msg164422 - (view) Author: Daniel Grace (dewin) Date: 2012-06-30 19:55
The documentation for os.utime() at http://docs.python.org/py3k/library/os.html#os.utime states: "Set the access and modified times of the file specified by path. [...] The effect is similar to running the Unix program touch on the path.)" Unlike 'touch', os.utime() will not create an empty file if called on a file that does not exist. IMO the current behavior is correct, but the comparison of os.utime() to touch implies that it would create empty files. I suggest clarifying the documentation to emphasize that os.utime() will not create new files and raises OSError in the event that the file does not exist.
msg164904 - (view) Author: Brian Brazil (bbrazil) * Date: 2012-07-07 16:17
Here's a patch that should clarify this.
msg165457 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2012-07-14 17:14
I don't think this needs clarifying. If you think the reference to "touch" currently only muddles the issue, let's remove it entirely.
msg199101 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-06 16:57
New changeset 62321359c35b by Georg Brandl in branch '3.3': Closes #15228: remove reference to Unix "touch"; it is confusing since the path needs to exist for os.utime() to succeed http://hg.python.org/cpython/rev/62321359c35b
History
Date User Action Args
2022-04-11 14:57:32 admin set github: 59433
2013-10-06 16:57:21 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2012-07-14 17:14:33 larry set messages: +
2012-07-07 21:15:12 larry set nosy: + larry
2012-07-07 16:17:37 bbrazil set files: + issue15228-utime-touch-doc.patchnosy: + bbrazilmessages: + keywords: + patch
2012-06-30 19:55:23 dewin create