[Python-checkins] python/dist/src/Python getargs.c, 2.102.2.3, 2.102.2.4

birkenfeld@users.sourceforge.net birkenfeld at users.sourceforge.net
Wed Sep 14 21:30:14 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12778/Python

Modified Files:
      Tag: release24-maint
	getargs.c 
Log Message:
Complete format code support in getargs.c::skipitem(), which is called when
evaluating keyword arguments.

CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS: 
CVS: Committing in .
CVS: 
CVS: Modified Files:
CVS: 	Python/getargs.c 
CVS: ----------------------------------------------------------------------


Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.102.2.3
retrieving revision 2.102.2.4
diff -u -d -r2.102.2.3 -r2.102.2.4
--- getargs.c	26 Aug 2005 06:43:16 -0000	2.102.2.3
+++ getargs.c	14 Sep 2005 19:30:11 -0000	2.102.2.4
@@ -453,7 +453,9 @@
    or a string with a message describing the failure.  The message is
    formatted as "must be <desired type>, not <actual type>".
    When failing, an exception may or may not have been raised.
-   Don't call if a tuple is expected. 
+   Don't call if a tuple is expected.
+
+   When you add new format codes, please don't forget poor skipitem() below.
 */
 
 static char *
@@ -1405,83 +1407,52 @@
 	char c = *format++;
 	
 	switch (c) {
-	
+
+	/* simple codes
+	 * The individual types (second arg of va_arg) are irrelevant */
+
 	case 'b': /* byte -- very short int */
 	case 'B': /* byte as bitfield */
-		{
-			(void) va_arg(*p_va, char *);
-			break;
-		}
-	
 	case 'h': /* short int */
-		{
-			(void) va_arg(*p_va, short *);
-			break;
-		}
-	
 	case 'H': /* short int as bitfield */
-		{
-			(void) va_arg(*p_va, unsigned short *);
-			break;
-		}
-	
 	case 'i': /* int */
-		{
-			(void) va_arg(*p_va, int *);
-			break;
-		}
-	
+	case 'I': /* int sized bitfield */
 	case 'l': /* long int */
-		{
-			(void) va_arg(*p_va, long *);
-			break;
-		}
-	
+	case 'k': /* long int sized bitfield */
 #ifdef HAVE_LONG_LONG
-	case 'L': /* PY_LONG_LONG int */
-		{
-			(void) va_arg(*p_va, PY_LONG_LONG *);
-			break;
-		}
+	case 'L': /* PY_LONG_LONG */
+	case 'K': /* PY_LONG_LONG sized bitfield */
 #endif
-	
 	case 'f': /* float */
-		{
-			(void) va_arg(*p_va, float *);
-			break;
-		}
-	
 	case 'd': /* double */
-		{
-			(void) va_arg(*p_va, double *);
-			break;
-		}
-	
 #ifndef WITHOUT_COMPLEX
 	case 'D': /* complex double */
-		{
-			(void) va_arg(*p_va, Py_complex *);
-			break;
-		}
-#endif /* WITHOUT_COMPLEX */
-	
+#endif
 	case 'c': /* char */
 		{
-			(void) va_arg(*p_va, char *);
+			(void) va_arg(*p_va, void *);
 			break;
 		}
 	
-	case 's': /* string */
+	/* string codes */
+		
+	case 'e': /* string with encoding */
 		{
-			(void) va_arg(*p_va, char **);
-			if (*format == '#') {
-				(void) va_arg(*p_va, int *);
-				format++;
-			}
-			break;
+			(void) va_arg(*p_va, const char *);
+			if (!(*format == 's' || *format == 't'))
+				/* after 'e', only 's' and 't' is allowed */
+				goto err;
+			format++;
+			/* explicit fallthrough to string cases */
 		}
 	
-	case 'z': /* string */
+	case 's': /* string */
+	case 'z': /* string or None */
+#ifdef Py_USING_UNICODE
+	case 'u': /* unicode string */
+#endif
+	case 't': /* buffer, read-only */
+	case 'w': /* buffer, read-write */
 		{
 			(void) va_arg(*p_va, char **);
 			if (*format == '#') {
@@ -1490,8 +1461,13 @@
 			}
 			break;
 		}
-	
+
+	/* object codes */
+
 	case 'S': /* string object */
+#ifdef Py_USING_UNICODE
+	case 'U': /* unicode string object */
+#endif
 		{
 			(void) va_arg(*p_va, PyObject **);
 			break;
@@ -1527,9 +1503,13 @@
 		}
 	
 	default:
+err:
 		return "impossible<bad format char>";
 	
 	}
+
+	/* The "(...)" format code for tuples is not handled here because
+	 * it is not allowed with keyword args. */
 	
 	*p_format = format;
 	return NULL;



More information about the Python-checkins mailing list