summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-10-14 20:00:05 (GMT)
committerGuido van Rossum <guido@python.org>1990-10-14 20:00:05 (GMT)
commit7d310eb0811fbf1fb9bc84156257a2e6abe9a5c2 (patch)
tree344bf06778d41662e387d9a1a9f71d69eb876335 /Python/errors.c
parentce4704a4f575073ae1cc62b30c4b15d64c7b40f7 (diff)
downloadcpython-7d310eb0811fbf1fb9bc84156257a2e6abe9a5c2.zip
cpython-7d310eb0811fbf1fb9bc84156257a2e6abe9a5c2.tar.gz
cpython-7d310eb0811fbf1fb9bc84156257a2e6abe9a5c2.tar.bz2
Adde dconvenience functions.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c31
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;
+}