diff mercurial/cext/pathencode.c @ 46374:e92ca942ddca

cext: add Python 3.10 support * Replace "Py_TYPE(obj) = type;" with "Py_SET_TYPE(obj, type);" * Add pythoncapi_compat.h header file to get Py_SET_TYPE() on Python 2.7-3.8. Header file added to mercurial/ and contrib/python-zstandard/zstd/common/. In Python 3.10, Py_TYPE(obj) must not longer be used as an l-value. pythoncapi_compat.h comes from: https://github.com/pythoncapi/pythoncapi_compat Differential Revision: https://phab.mercurial-scm.org/D9825
author Victor Stinner <vstinner@python.org>
date Mon, 14 Dec 2020 10:44:29 +0100
parents 763b45bc4483
children e35807332598
line wrap: on
line diff
--- a/mercurial/cext/pathencode.c	Wed Jan 20 14:47:13 2021 +0100
+++ b/mercurial/cext/pathencode.c	Mon Dec 14 10:44:29 2020 +0100
@@ -21,6 +21,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include "pythoncapi_compat.h"
 
 #include "util.h"
 
@@ -678,7 +679,7 @@
 	}
 
 	assert(PyBytes_Check(ret));
-	Py_SIZE(ret) = destlen;
+	Py_SET_SIZE(ret, destlen);
 
 	return ret;
 }