[PATCH] pathencode: use assert() for PyBytes_Check()

Gregory Szorc gregory.szorc at gmail.com
Thu Oct 13 19:42:42 UTC 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1476387731 -7200
#      Thu Oct 13 21:42:11 2016 +0200
# Node ID 4bbdf012fafbdffd4d4402a712fdc01d3252d00c
# Parent  c0410814002f467c24ef07ce73850ba15b306f8e
pathencode: use assert() for PyBytes_Check()

This should have been added in a8c948ee3668. I sent the patch to the
list prematurely.

diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
--- a/mercurial/pathencode.c
+++ b/mercurial/pathencode.c
@@ -638,9 +638,9 @@ static PyObject *hashmangle(const char *
 	if (lastdot >= 0)
 		memcopy(dest, &destlen, destsize, &src[lastdot],
 			len - lastdot - 1);
 
-	PyBytes_Check(ret);
+	assert(PyBytes_Check(ret));
 	Py_SIZE(ret) = destlen;
 
 	return ret;
 }
@@ -751,9 +751,9 @@ PyObject *pathencode(PyObject *self, PyO
 
 		newobj = PyBytes_FromStringAndSize(NULL, newlen);
 
 		if (newobj) {
-			PyBytes_Check(newobj);
+			assert(PyBytes_Check(newobj));
 			Py_SIZE(newobj)--;
 			basicencode(PyBytes_AS_STRING(newobj), newlen, path,
 				    len + 1);
 		}


More information about the Mercurial-devel mailing list