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

Antoine Pitrou solipsis at pitrou.net
Mon Sep 16 14:36:08 CDT 2013


On Mon, 16 Sep 2013 12:27:31 -0700
Bryan O'Sullivan <bos at serpentine.com> wrote:
> # 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);
> +	}

Are you sure about that?
I can't think of a situation where you'd want to incref something after
untracking it (normally PyObject_GC_UnTrack should only be used in a
tp_dealloc function).

Regards

Antoine.




More information about the Mercurial-devel mailing list