[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.132,2.133

Barry A. Warsaw python-dev@python.org
Mon, 1 May 2000 12:17:27 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Modules
In directory anthem:/home/bwarsaw/projects/python/Modules

Modified Files:
	posixmodule.c 
Log Message:
posix_utime(): Allow the second argument to be None, which invokes the
utime(path, NULL) call, setting the atime and mtime of the file to the
current time.  The previous signature utime(path, (atime, mtime)) is
of course still allowed.


Index: posixmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.132
retrieving revision 2.133
diff -C2 -r2.132 -r2.133
*** posixmodule.c	2000/04/26 20:34:28	2.132
--- posixmodule.c	2000/05/01 16:17:24	2.133
***************
*** 1251,1255 ****
  static char posix_utime__doc__[] =
  "utime(path, (atime, utime)) -> None\n\
! Set the access and modified time of the file to the given values.";
  
  static PyObject *
--- 1251,1257 ----
  static char posix_utime__doc__[] =
  "utime(path, (atime, utime)) -> None\n\
! utime(path, None) -> None\n\
! Set the access and modified time of the file to the given values.  If the\n\
! second form is used, set the access and modified times to the current time.";
  
  static PyObject *
***************
*** 1261,1264 ****
--- 1263,1267 ----
  	long atime, mtime;
  	int res;
+ 	PyObject* arg;
  
  /* XXX should define struct utimbuf instead, above */
***************
*** 1275,1285 ****
  #endif /* HAVE_UTIME_H */
  
! 	if (!PyArg_ParseTuple(args, "s(ll):utime", &path, &atime, &mtime))
  		return NULL;
! 	ATIME = atime;
! 	MTIME = mtime;
! 	Py_BEGIN_ALLOW_THREADS
! 	res = utime(path, UTIME_ARG);
! 	Py_END_ALLOW_THREADS
  	if (res < 0)
  		return posix_error_with_filename(path);
--- 1278,1301 ----
  #endif /* HAVE_UTIME_H */
  
! 	if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
  		return NULL;
! 	if (arg == Py_None) {
! 		/* optional time values not given */
! 		Py_BEGIN_ALLOW_THREADS
! 		res = utime(path, NULL);
! 		Py_END_ALLOW_THREADS
! 	}
! 	else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
! 		PyErr_SetString(PyExc_TypeError,
! 			      "Second argument must be a 2-tuple of numbers.");
! 		return NULL;
! 	}
! 	else {
! 		ATIME = atime;
! 		MTIME = mtime;
! 		Py_BEGIN_ALLOW_THREADS
! 		res = utime(path, UTIME_ARG);
! 		Py_END_ALLOW_THREADS
! 	}
  	if (res < 0)
  		return posix_error_with_filename(path);