Patchwork pathencode: use assert() for PyBytes_Check()

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 13, 2016, 7:42 p.m.
Message ID <4bbdf012fafbdffd4d44.1476387762@gps-mbp.local>
Download mbox | patch
Permalink /patch/17057/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 13, 2016, 7:42 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.
Yuya Nishihara - Oct. 14, 2016, 2:53 p.m.
On Thu, 13 Oct 2016 21:42:42 +0200, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1476387731 -7200
> #      Thu Oct 13 21:42:11 2016 +0200
> # Node ID 4bbdf012fafbdffd4d4402a712fdc01d3252d00c
> # Parent  c0410814002f467c24ef07ce73850ba15b306f8e
> pathencode: use assert() for PyBytes_Check()

Queued, thanks!

Patch

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);
 		}