Kaydet (Commit) 7d310eb0 authored tarafından Guido van Rossum's avatar Guido van Rossum

Adde dconvenience functions.

üst ce4704a4
......@@ -109,3 +109,34 @@ err_clear()
last_exc_val = NULL;
}
}
/* Convenience functions to set a type error exception and return 0 */
int
err_badarg()
{
err_setstr(TypeError, "illegal argument type for built-in function");
return 0;
}
object *
err_nomem()
{
err_setstr(MemoryError, "in built-in function");
return NULL;
}
object *
err_errno(exc)
object *exc;
{
object *v = newtupleobject(2);
if (v != NULL) {
settupleitem(v, 0, newintobject((long)errno));
settupleitem(v, 1, newstringobject(strerror(errno)));
}
err_setval(exc, v);
if (v != NULL)
DECREF(v);
return NULL;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment