diff options
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index ac34742..91ae730 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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; +} |