[PATCH] dirs: document Py_SIZE weirdness
Gregory Szorc
gregory.szorc at gmail.com
Thu Oct 13 19:43:40 UTC 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1475939263 -7200
# Sat Oct 08 17:07:43 2016 +0200
# Node ID c05716f3eb0a4a70ef1f59b51cd1b29ee683a145
# Parent c0410814002f467c24ef07ce73850ba15b306f8e
dirs: document Py_SIZE weirdness
Assigning to what looks like a function is clown shoes. Document that
it is a macro referring to a struct member.
diff --git a/mercurial/dirs.c b/mercurial/dirs.c
--- a/mercurial/dirs.c
+++ b/mercurial/dirs.c
@@ -75,8 +75,10 @@ static int _addpath(PyObject *dirs, PyOb
pos < 2 ? 2 : pos);
if (key == NULL)
goto bail;
}
+ /* Py_SIZE(o) refers to the ob_size member of the struct. Yes,
+ * assigning to what looks like a function seems wrong. */
Py_SIZE(key) = pos;
((PyBytesObject *)key)->ob_sval[pos] = '\0';
val = PyDict_GetItem(dirs, key);
More information about the Mercurial-devel
mailing list