Skip to content

Commit

Permalink
Patch #1576166: Support os.utime for directories on Windows NT+.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.python.org/projects/python/trunk@52335 6015fed2-1504-0410-9fe1-9d1591cc4771
  • Loading branch information
martin.v.loewis committed Oct 15, 2006
1 parent 910740b commit 118be6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ def test_statvfs_attributes(self):
except TypeError:
pass

def test_utime_dir(self):
delta = 1000000
st = os.stat(test_support.TESTFN)
os.utime(test_support.TESTFN, (st.st_atime, st.st_mtime-delta))
st2 = os.stat(test_support.TESTFN)
self.assertEquals(st2.st_mtime, st.st_mtime-delta)

# Restrict test to Win32, since there is no guarantee other
# systems support centiseconds
if sys.platform == 'win32':
Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Library
Extension Modules
-----------------

- Patch #1576166: Support os.utime for directories on Windows NT+.

- Bug #1548891: The cStringIO.StringIO() constructor now encodes unicode
arguments with the system default encoding just like the write()
method does, instead of converting it to a raw buffer.
Expand Down
7 changes: 5 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,8 @@ posix_utime(PyObject *self, PyObject *args)
wpath = PyUnicode_AS_UNICODE(obwpath);
Py_BEGIN_ALLOW_THREADS
hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0,
NULL, OPEN_EXISTING, 0, NULL);
NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
Py_END_ALLOW_THREADS
if (hFile == INVALID_HANDLE_VALUE)
return win32_error_unicode("utime", wpath);
Expand All @@ -2473,7 +2474,8 @@ posix_utime(PyObject *self, PyObject *args)
return NULL;
Py_BEGIN_ALLOW_THREADS
hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0,
NULL, OPEN_EXISTING, 0, NULL);
NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
Py_END_ALLOW_THREADS
if (hFile == INVALID_HANDLE_VALUE) {
win32_error("utime", apath);
Expand Down Expand Up @@ -8617,3 +8619,4 @@ INITFUNC(void)
}
#endif


0 comments on commit 118be6c

Please sign in to comment.