[Python-checkins] CVS: python/dist/src/Python getargs.c,2.88,2.89

Tim Peters tim_one@users.sourceforge.net
Wed, 28 Nov 2001 19:26:39 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv22096/python/Python

Modified Files:
	getargs.c 
Log Message:
SF bug 486278 SystemError: Python/getargs.c:1086: bad.
vgetargskeywords():  Now that this routine is checking for bad input
(rather than dump core in some cases), some bad calls are raising errors
that previously "worked".  This patch makes the error strings more
revealing, and changes the exceptions from SystemError to RuntimeError
(under the theory that SystemError is more of a "can't happen!" assert-
like thing, and so inappropriate for bad arguments to a public C API
function).


Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.88
retrieving revision 2.89
diff -C2 -d -r2.88 -r2.89
*** getargs.c	2001/11/28 22:14:37	2.88
--- getargs.c	2001/11/29 03:26:37	2.89
***************
*** 1050,1054 ****
  	/* Search the format:
  	   message <- error msg, if any (else NULL).
! 	   name <- routine name, if any (else NULL).
  	   min <- # of required arguments, or -1 if all are required.
  	   max <- most arguments (required + optional).
--- 1050,1054 ----
  	/* Search the format:
  	   message <- error msg, if any (else NULL).
! 	   fname <- routine name, if any (else NULL).
  	   min <- # of required arguments, or -1 if all are required.
  	   max <- most arguments (required + optional).
***************
*** 1065,1070 ****
  			max++;
  			if (*p == NULL) {
! 				/* kwlist is too short */
! 				PyErr_BadInternalCall();
  				return 0;
  			}
--- 1065,1071 ----
  			max++;
  			if (*p == NULL) {
! 				PyErr_SetString(PyExc_RuntimeError,
! 					"more argument specifiers than "
! 					"keyword list entries");
  				return 0;
  			}
***************
*** 1082,1087 ****
  		}
  		else if (i == '(') {
! 			PyErr_SetString(PyExc_SystemError,
! 		      "tuple found in format when using keyword arguments");
  			return 0;
  		}
--- 1083,1089 ----
  		}
  		else if (i == '(') {
! 			PyErr_SetString(PyExc_RuntimeError,
! 				"tuple found in format when using keyword "
! 				"arguments");
  			return 0;
  		}
***************
*** 1089,1094 ****
  	format = formatsave;
  	if (*p != NULL) {
! 		/* kwlist is too long */
! 		PyErr_BadInternalCall();
  		return 0;
  	}
--- 1091,1097 ----
  	format = formatsave;
  	if (*p != NULL) {
! 		PyErr_SetString(PyExc_RuntimeError,
! 			"more keyword list entries than "
! 			"argument specifiers");
  		return 0;
  	}