[PATCH 2 of 3 in crew] parsers: use Py_INCREF safely

Bryan O'Sullivan bos at serpentine.com
Mon Sep 16 14:27:31 CDT 2013


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1379358757 25200
#      Mon Sep 16 12:12:37 2013 -0700
# Node ID b3c8c6f2b5c146c9d3464058ff40d031a97b371d
# Parent  5e25d71a58cc93627f635bae699602dc7bb8afcf
parsers: use Py_INCREF safely

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -540,11 +540,12 @@ static PyObject *index_get(indexObject *
 			      uncomp_len, base_rev, link_rev,
 			      parent_1, parent_2, c_node_id, 20);
 
-	if (entry)
+	if (entry) {
 		PyObject_GC_UnTrack(entry);
+		Py_INCREF(entry);
+	}
 
 	self->cache[pos] = entry;
-	Py_INCREF(entry);
 
 	return entry;
 }


More information about the Mercurial-devel mailing list