summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-01-03 00:40:04 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-01-03 00:40:04 (GMT)
commit32e8aab1fbb809f3e4bd0830f0b0602349f21a02 (patch)
treea66058db44aa556e732c999fd1e5a725d106b4b5 /Modules
parentd4bf48bbb3d8aa63e48abafff44928468f593221 (diff)
downloadcpython-32e8aab1fbb809f3e4bd0830f0b0602349f21a02.zip
cpython-32e8aab1fbb809f3e4bd0830f0b0602349f21a02.tar.gz
cpython-32e8aab1fbb809f3e4bd0830f0b0602349f21a02.tar.bz2
Merged revisions 87666 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87666 | amaury.forgeotdarc | 2011-01-03 01:19:11 +0100 (lun., 03 janv. 2011) | 4 lines #8278: In the Windows implementation of stat() and utime(), use time_t instead of int. This gives support for dates after 2038, at least when compiled with VS2003 or later, where time_t is 64bit. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index a3feb24..cb94898 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -939,18 +939,18 @@ struct win32_stat{
int st_gid;
int st_rdev;
__int64 st_size;
- int st_atime;
+ time_t st_atime;
int st_atime_nsec;
- int st_mtime;
+ time_t st_mtime;
int st_mtime_nsec;
- int st_ctime;
+ time_t st_ctime;
int st_ctime_nsec;
};
static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */
static void
-FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out)
+FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, time_t *time_out, int* nsec_out)
{
/* XXX endianness. Shouldn't matter, as all Windows implementations are little-endian */
/* Cannot simply cast and dereference in_ptr,
@@ -958,12 +958,11 @@ FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out)
__int64 in;
memcpy(&in, in_ptr, sizeof(in));
*nsec_out = (int)(in % 10000000) * 100; /* FILETIME is in units of 100 nsec. */
- /* XXX Win32 supports time stamps past 2038; we currently don't */
- *time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, int);
+ *time_out = Py_SAFE_DOWNCAST((in / 10000000) - secs_between_epochs, __int64, time_t);
}
static void
-time_t_to_FILE_TIME(int time_in, int nsec_in, FILETIME *out_ptr)
+time_t_to_FILE_TIME(time_t time_in, int nsec_in, FILETIME *out_ptr)
{
/* XXX endianness */
__int64 out;
@@ -2912,15 +2911,19 @@ posix_uname(PyObject *self, PyObject *noargs)
#endif /* HAVE_UNAME */
static int
-extract_time(PyObject *t, long* sec, long* usec)
+extract_time(PyObject *t, time_t* sec, long* usec)
{
- long intval;
+ time_t intval;
if (PyFloat_Check(t)) {
double tval = PyFloat_AsDouble(t);
- PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t);
+ PyObject *intobj = PyNumber_Long(t);
if (!intobj)
return -1;
+#if SIZEOF_TIME_T > SIZEOF_LONG
+ intval = PyLong_AsUnsignedLongLongMask(intobj);
+#else
intval = PyLong_AsLong(intobj);
+#endif
Py_DECREF(intobj);
if (intval == -1 && PyErr_Occurred())
return -1;
@@ -2932,7 +2935,11 @@ extract_time(PyObject *t, long* sec, long* usec)
*usec = 0;
return 0;
}
+#if SIZEOF_TIME_T > SIZEOF_LONG
+ intval = PyLong_AsUnsignedLongLongMask(t);
+#else
intval = PyLong_AsLong(t);
+#endif
if (intval == -1 && PyErr_Occurred())
return -1;
*sec = intval;
@@ -2956,7 +2963,8 @@ posix_utime(PyObject *self, PyObject *args)
PyObject *oapath;
char *apath;
HANDLE hFile;
- long atimesec, mtimesec, ausec, musec;
+ time_t atimesec, mtimesec;
+ long ausec, musec;
FILETIME atime, mtime;
PyObject *result = NULL;
@@ -3033,7 +3041,8 @@ done:
PyObject *opath;
char *path;
- long atime, mtime, ausec, musec;
+ time_t atime, mtime;
+ long ausec, musec;
int res;
PyObject* arg;