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

Guido van Rossum python-dev@python.org
Thu, 30 Mar 2000 19:47:30 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Modules
In directory eric:/projects/python/develop/guido/src/Modules

Modified Files:
	posixmodule.c 
Log Message:
Two robustness patches:

(1) In opendir(), don't call the lock-release macros; we're
manipulating list objects and that shouldn't be done in unlocked
state.

(2) Don't use posix_strint() for chmod() -- the mode_t arg might be a
64 bit int (reported by Nick Maclaren).


Index: posixmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.126
retrieving revision 2.127
diff -C2 -r2.126 -r2.127
*** posixmodule.c	2000/03/01 21:51:56	2.126
--- posixmodule.c	2000/03/31 00:47:28	2.127
***************
*** 693,697 ****
  	PyObject *args;
  {
! 	return posix_strint(args, "si:chmod", chmod);
  }
  
--- 693,708 ----
  	PyObject *args;
  {
! 	char *path;
! 	int i;
! 	int res;
! 	if (!PyArg_ParseTuple(args, format, &path, &i))
! 		return NULL;
! 	Py_BEGIN_ALLOW_THREADS
! 	res = chmod(path, i);
! 	Py_END_ALLOW_THREADS
! 	if (res < 0)
! 		return posix_error_with_filename(path);
! 	Py_INCREF(Py_None);
! 	return Py_None;
  }
  
***************
*** 999,1010 ****
  	if (!PyArg_ParseTuple(args, "s:listdir", &name))
  		return NULL;
- 	Py_BEGIN_ALLOW_THREADS
  	if ((dirp = opendir(name)) == NULL) {
- 		Py_BLOCK_THREADS
  		return posix_error_with_filename(name);
  	}
  	if ((d = PyList_New(0)) == NULL) {
  		closedir(dirp);
- 		Py_BLOCK_THREADS
  		return NULL;
  	}
--- 1010,1018 ----
***************
*** 1029,1033 ****
  	}
  	closedir(dirp);
- 	Py_END_ALLOW_THREADS
  
  	return d;
--- 1037,1040 ----