comparison Python/errors.c @ 6319:b7f0b98f5325 legacy-trunk

New API PyErr_NewException(name, base, dict) to create simple new exceptions.
author Guido van Rossum <guido@python.org>
date Tue, 16 Sep 1997 18:43:50 +0000
parents b5757e87eb32
children 9e82dd76288e
comparison
equal deleted inserted replaced
6318:cdc5a40fcf97 6319:b7f0b98f5325
316 316
317 vsprintf(buffer, format, vargs); 317 vsprintf(buffer, format, vargs);
318 PyErr_SetString(exception, buffer); 318 PyErr_SetString(exception, buffer);
319 return NULL; 319 return NULL;
320 } 320 }
321
322
323 PyObject *
324 PyErr_NewException(name, base, dict)
325 char *name;
326 PyObject *base;
327 PyObject *dict;
328 {
329 PyObject *nname = PyString_InternFromString(name);
330 PyObject *ndict = NULL;
331 PyObject *nbases = NULL;
332 PyObject *result = NULL;
333 if (nname == NULL)
334 return NULL;
335 if (dict == NULL) {
336 dict = ndict = PyDict_New();
337 if (dict == NULL)
338 goto failure;
339 }
340 if (base == NULL)
341 base = PyExc_Exception;
342 nbases = Py_BuildValue("(O)", base);
343 if (nbases == NULL)
344 goto failure;
345 result = PyClass_New(nbases, dict, nname);
346 failure:
347 Py_XDECREF(nbases);
348 Py_XDECREF(ndict);
349 Py_XDECREF(nname);
350 return result;
351 }