diff Python/modsupport.c @ 1211:406860dfaac7 legacy-trunk

* stdwinmodule.c: various new commands: setwin{pos,size}, listfontnames, bitmap ops. * listobject.c: use mkvalue() when possible; avoid weird error when calling append() without args. * modsupport.c: new feature in getargs(): if the format string contains a semicolor the string after that is used as the error message instead of "bad argument list (format %s)" when there's an error.
author Guido van Rossum <guido@python.org>
date Mon, 08 Feb 1993 15:49:17 +0000
parents 2937897a7d8b
children c4cd0d9d8281
line wrap: on
line diff
--- a/Python/modsupport.c	Fri Feb 05 15:34:22 1993 +0000
+++ b/Python/modsupport.c	Mon Feb 08 15:49:17 1993 +0000
@@ -70,7 +70,7 @@
 }
 
 
-/* Helper for getargs() and mkvalue() to scan the length of a format */
+/* Helper for mkvalue() to scan the length of a format */
 
 static int countformat PROTO((char *format, int endchar));
 static int countformat(format, endchar)
@@ -292,24 +292,34 @@
 	arg = va_arg(va, object *);
 	format = va_arg(va, char *);
 #endif
-	if (*format == '\0') {
+	if (*format == '\0' || *format == ';') {
 		va_end(va);
 		if (arg != NULL) {
-			err_setstr(TypeError, "no arguments needed");
+			char *str = "no arguments needed";
+			if (*format == ';')
+				str = format+1;
+			err_setstr(TypeError, str);
 			return 0;
 		}
 		return 1;
 	}
 	
 	f = format;
-	ok = do_arg(arg, &f, &va) && *f == '\0';
+	ok = do_arg(arg, &f, &va) && (*f == '\0' || *f == ';');
 	va_end(va);
 	if (!ok) {
-		char buf[256];
 		if (!err_occurred()) {
-			sprintf(buf, "bad argument list (format '%s')",
-				format);
-			err_setstr(TypeError, buf);
+			char buf[256];
+			char *str;
+			f = strchr(format, ';');
+			if (f != NULL)
+				str = f+1;
+			else {
+				sprintf(buf, "bad argument list (format '%s')",
+					format);
+				str = buf;
+			}
+			err_setstr(TypeError, str);
 		}
 	}
 	return ok;