Patchwork [2,of,5,foldmap-in-C,V2] parsers._asciilower: use an explicit return object

login
register
mail settings
Submitter Siddharth Agarwal
Date April 1, 2015, 9 p.m.
Message ID <d00904680bc9a864604f.1427922000@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8427/
State Accepted
Commit a62e957413f7d24d7d0cd14561033337d09e1dca
Headers show

Comments

Siddharth Agarwal - April 1, 2015, 9 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1427921931 25200
#      Wed Apr 01 13:58:51 2015 -0700
# Node ID d00904680bc9a864604fa23e19480e60b7fc6feb
# Parent  d624f49c6f5f4741b8cdd1b3c8a9d2a305893c8c
parsers._asciilower: use an explicit return object

No functional change, but this will make upcoming patches cleaner.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -98,6 +98,7 @@ 
 	char *str, *newstr;
 	Py_ssize_t i, len;
 	PyObject *newobj = NULL;
+	PyObject *ret = NULL;
 
 	str = PyBytes_AS_STRING(str_obj);
 	len = PyBytes_GET_SIZE(str_obj);
@@ -121,10 +122,11 @@ 
 		newstr[i] = lowertable[(unsigned char)c];
 	}
 
-	return newobj;
+	ret = newobj;
+	Py_INCREF(ret);
 quit:
 	Py_XDECREF(newobj);
-	return NULL;
+	return ret;
 }
 
 static PyObject *asciilower(PyObject *self, PyObject *args)