[Python-checkins] r46408 - python/branches/sreifschneider-newnewexcept/Python/errors.c

georg.brandl python-checkins at python.org
Fri May 26 21:59:05 CEST 2006


Author: georg.brandl
Date: Fri May 26 21:59:04 2006
New Revision: 46408

Modified:
   python/branches/sreifschneider-newnewexcept/Python/errors.c
Log:
Some simplifications.



Modified: python/branches/sreifschneider-newnewexcept/Python/errors.c
==============================================================================
--- python/branches/sreifschneider-newnewexcept/Python/errors.c	(original)
+++ python/branches/sreifschneider-newnewexcept/Python/errors.c	Fri May 26 21:59:04 2006
@@ -566,7 +566,7 @@
 		if (bases == NULL)
 			goto failure;
 	}
-	/*result = PyClass_New(bases, dict, classname);*/
+	/* Create a real new-style class. */
 	result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO",
 				       dot+1, bases, dict);
   failure:
@@ -643,15 +643,11 @@
 		return 0;
 	}
 	else {
-		PyObject *args, *res;
+		PyObject *res;
 
 		if (category == NULL)
 			category = PyExc_RuntimeWarning;
-		args = Py_BuildValue("(sO)", message, category);
-		if (args == NULL)
-			return -1;
-		res = PyEval_CallObject(func, args);
-		Py_DECREF(args);
+		res = PyObject_CallFunction(func, "sO", message, category);
 		if (res == NULL)
 			return -1;
 		Py_DECREF(res);
@@ -679,18 +675,14 @@
 		return 0;
 	}
 	else {
-		PyObject *args, *res;
+		PyObject *res;
 
 		if (category == NULL)
 			category = PyExc_RuntimeWarning;
 		if (registry == NULL)
 			registry = Py_None;
-		args = Py_BuildValue("(sOsizO)", message, category,
-				     filename, lineno, module, registry);
-		if (args == NULL)
-			return -1;
-		res = PyEval_CallObject(func, args);
-		Py_DECREF(args);
+		res = PyObject_CallFunction(func, "sOsizO", message, category,
+					    filename, lineno, module, registry);
 		if (res == NULL)
 			return -1;
 		Py_DECREF(res);
@@ -711,7 +703,8 @@
 	/* add attributes for the line number and filename for the error */
 	PyErr_Fetch(&exc, &v, &tb);
 	PyErr_NormalizeException(&exc, &v, &tb);
-	/* XXX check that it is, indeed, a syntax error */
+	/* XXX check that it is, indeed, a syntax error. It might not
+	 * be, though. */
 	tmp = PyInt_FromLong(lineno);
 	if (tmp == NULL)
 		PyErr_Clear();


More information about the Python-checkins mailing list