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.

classification
Title: os.utime() docs not clear on behavior on nonexistant files
Type: enhancement Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: bbrazil, dewin, docs@python, larry, python-dev
Priority: normal Keywords: patch

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:32adminsetgithub: 59433
2013-10-06 16:57:21python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg199101

resolution: fixed
stage: resolved
2012-07-14 17:14:33larrysetmessages: + msg165457
2012-07-07 21:15:12larrysetnosy: + larry
2012-07-07 16:17:37bbrazilsetfiles: + issue15228-utime-touch-doc.patch

nosy: + bbrazil
messages: + msg164904

keywords: + patch
2012-06-30 19:55:23dewincreate