From e13ff2e2d6ddc6dead2d804006d8320df27dc553 Mon Sep 17 00:00:00 2001
From: Guido van Rossum <guido@python.org>
Date: Mon, 27 Sep 1999 17:12:47 +0000
Subject: Patch by Tim Peters fixing PR#88:

Integer division can crash under Windows.
---
 Objects/intobject.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Objects/intobject.c b/Objects/intobject.c
index 7293515..f2d77e1 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -434,8 +434,14 @@ i_divmod(x, y, p_xdivy, p_xmody)
 		return -1;
 	}
 	if (yi < 0) {
-		if (xi < 0)
+		if (xi < 0) {
+			if (yi == -1 && -xi < 0) {
+				/* most negative / -1 */
+				err_ovf("integer division");
+				return -1;
+			}
 			xdivy = -xi / -yi;
+		}
 		else
 			xdivy = - (xi / -yi);
 	}
-- 
cgit v0.12

