Mercurial > hg-stable
comparison mercurial/cext/pathencode.c @ 46446: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 |
comparison
equal
deleted
inserted
replaced
46445:711ba0f1057e | 46446:e92ca942ddca |
---|---|
19 #include <Python.h> | 19 #include <Python.h> |
20 #include <assert.h> | 20 #include <assert.h> |
21 #include <ctype.h> | 21 #include <ctype.h> |
22 #include <stdlib.h> | 22 #include <stdlib.h> |
23 #include <string.h> | 23 #include <string.h> |
24 #include "pythoncapi_compat.h" | |
24 | 25 |
25 #include "util.h" | 26 #include "util.h" |
26 | 27 |
27 /* state machine for the fast path */ | 28 /* state machine for the fast path */ |
28 enum path_state { | 29 enum path_state { |
676 memcopy(dest, &destlen, destsize, &src[lastdot], | 677 memcopy(dest, &destlen, destsize, &src[lastdot], |
677 len - lastdot - 1); | 678 len - lastdot - 1); |
678 } | 679 } |
679 | 680 |
680 assert(PyBytes_Check(ret)); | 681 assert(PyBytes_Check(ret)); |
681 Py_SIZE(ret) = destlen; | 682 Py_SET_SIZE(ret, destlen); |
682 | 683 |
683 return ret; | 684 return ret; |
684 } | 685 } |
685 | 686 |
686 /* | 687 /* |