]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Adde dconvenience functions.
authorGuido van Rossum <guido@python.org>
Sun, 14 Oct 1990 20:00:05 +0000 (20:00 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 14 Oct 1990 20:00:05 +0000 (20:00 +0000)
Python/errors.c

index ac34742a31e9cf9e0774c7218c32bdc87d45e19a..91ae730ae6e916bb2fa08b48bb72eb492196bee2 100644 (file)
@@ -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;
+}