summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-09-11 13:55:55 (GMT)
committerGuido van Rossum <guido@python.org>1996-09-11 13:55:55 (GMT)
commitee09fc1c3052a0dc2c6557431cb31e1197917ce1 (patch)
tree590d4ee57c2b3dc0ff54dce912f23a24495b2d90 /Objects/complexobject.c
parent946cf890d45010c203bfba08d30d122574b4a411 (diff)
downloadcpython-ee09fc1c3052a0dc2c6557431cb31e1197917ce1.zip
cpython-ee09fc1c3052a0dc2c6557431cb31e1197917ce1.tar.gz
cpython-ee09fc1c3052a0dc2c6557431cb31e1197917ce1.tar.bz2
Don't dump core on complex % or divmod -- raise a TypeError exception.
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 89a7380..063f3e0 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -370,6 +370,18 @@ complex_div(v, w)
return newcomplexobject(quot);
}
+static object *
+complex_remainder(v, w)
+ complexobject *v;
+ complexobject *w;
+{
+ err_setstr(TypeError,
+ "remainder and divmod not implemented for complex numbers");
+ return NULL;
+}
+
+#define complex_divmod complex_remainder
+
static object *
complex_pow(v, w, z)
@@ -544,8 +556,8 @@ static number_methods complex_as_number = {
(binaryfunc)complex_sub, /*nb_subtract*/
(binaryfunc)complex_mul, /*nb_multiply*/
(binaryfunc)complex_div, /*nb_divide*/
- 0, /*nb_remainder*/
- 0, /*nb_divmod*/
+ (binaryfunc)complex_remainder, /*nb_remainder*/
+ (binaryfunc)complex_divmod, /*nb_divmod*/
(ternaryfunc)complex_pow, /*nb_power*/
(unaryfunc)complex_neg, /*nb_negative*/
(unaryfunc)complex_pos, /*nb_positive*/