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

Fredrik Lundh python-dev@python.org
Sun, 9 Jul 2000 10:41:04 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv3773/Modules

Modified Files:
	posixmodule.c 
Log Message:


- added optional bufsize argument to new popen methods.
  for the moment, this argument must be left out or set
  to -1 (only the default bufsize is supported, that is)

Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.145
retrieving revision 2.146
diff -C2 -r2.145 -r2.146
*** posixmodule.c	2000/07/09 14:49:51	2.145
--- posixmodule.c	2000/07/09 17:41:01	2.146
***************
*** 2156,2160 ****
  	char *cmdstring;
  	char *mode = "r";
! 	if (!PyArg_ParseTuple(args, "s|s:popen", &cmdstring, &mode))
  		return NULL;
  
--- 2156,2160 ----
  	char *cmdstring;
  	char *mode = "r";
! 	if (!PyArg_ParseTuple(args, "s|si:popen", &cmdstring, &mode, &bufsize))
  		return NULL;
  
***************
*** 2169,2172 ****
--- 2169,2177 ----
  		tm = _O_WRONLY;
  	 
+ 	if (bufsize != -1) {
+ 		PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ 		return NULL;
+ 	}
+ 
  	if (*(mode+1) == 't')
  		f = _PyPopen(cmdstring, tm | _O_TEXT , POPEN_1);
***************
*** 2193,2197 ****
  	char *cmdstring;
  	char *mode = "t";
! 	if (!PyArg_ParseTuple(args, "s|s:popen2", &cmdstring, &mode))
  		return NULL;
    
--- 2198,2203 ----
  	char *cmdstring;
  	char *mode = "t";
! 	int bufsize = -1;
! 	if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize))
  		return NULL;
    
***************
*** 2204,2208 ****
  		tm = _O_BINARY;
    
! 	f = _PyPopen(cmdstring, tm , POPEN_2);
    
  	return f;
--- 2210,2219 ----
  		tm = _O_BINARY;
    
! 	if (bufsize != -1) {
! 		PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
! 		return NULL;
! 	}
! 
! 	f = _PyPopen(cmdstring, tm, POPEN_2);
    
  	return f;
***************
*** 2224,2228 ****
  	char *cmdstring;
  	char *mode = "t";
! 	if (!PyArg_ParseTuple(args, "s|s:Popen3", &cmdstring, &mode))
  		return NULL;
    
--- 2235,2240 ----
  	char *cmdstring;
  	char *mode = "t";
! 	int bufsize = -1;
! 	if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize))
  		return NULL;
    
***************
*** 2235,2238 ****
--- 2247,2255 ----
  		tm = _O_BINARY;
    
+ 	if (bufsize != -1) {
+ 		PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ 		return NULL;
+ 	}
+ 
  	f = _PyPopen(cmdstring, tm, POPEN_3);
    
***************
*** 2255,2259 ****
  	char *cmdstring;
  	char *mode = "t";
! 	if (!PyArg_ParseTuple(args, "s|s:popen4", &cmdstring, &mode))
  		return NULL;
    
--- 2272,2277 ----
  	char *cmdstring;
  	char *mode = "t";
! 	int bufsize = -1;
! 	if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize))
  		return NULL;
    
***************
*** 2265,2271 ****
  	} else
  		tm = _O_BINARY;
!   
  	f = _PyPopen(cmdstring, tm , POPEN_4);
!   
  	return f;
  }
--- 2283,2294 ----
  	} else
  		tm = _O_BINARY;
! 
! 	if (bufsize != -1) {
! 		PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
! 		return NULL;
! 	}
! 
  	f = _PyPopen(cmdstring, tm , POPEN_4);
! 
  	return f;
  }