From 6b18a5bb3228b7af47d23941bb74d0224e2540d0 Mon Sep 17 00:00:00 2001
From: Guido van Rossum <guido@python.org>
Date: Thu, 29 Mar 2007 20:49:57 +0000
Subject: Fix refcounting bug reported by Amaury Forgeot d'Arc.

---
 Objects/typeobject.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index be6f279..1ccd97b 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2311,6 +2311,7 @@ object_richcompare(PyObject *self, PyObject *other, int op)
 
 	case Py_EQ:
 		res = (self == other) ? Py_True : Py_False;
+		Py_INCREF(res);
 		break;
 
 	case Py_NE:
@@ -2334,10 +2335,10 @@ object_richcompare(PyObject *self, PyObject *other, int op)
 
 	default:
 		res = Py_NotImplemented;
+		Py_INCREF(res);
 		break;
 	}
 
-	Py_INCREF(res);
 	return res;
 }
 
-- 
cgit v0.12

