[PATCH 1 of 4 stable] cext: fix for PyLong refactoring in CPython 3.12
Raphaël Gomès
raphael.gomes at octobus.net
Mon Mar 20 19:20:23 UTC 2023
Queued¹ (by Pierre-Yves, reviewed by me) all except the redundant
Cargo.toml patch with slightly one modified patch due to formatting.
[1]
https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/505/
On 3/7/23 19:23, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <mads at kiilerich.com>
> # Date 1678202751 -3600
> # Tue Mar 07 16:25:51 2023 +0100
> # Branch stable
> # Node ID 1efa4e96f6461bf071b28d66b13bdb67fdc91fc6
> # Parent 8a65b43457aba02741bedabe100823d3041af0b5
> cext: fix for PyLong refactoring in CPython 3.12
>
> Compiling Mercurial with Python 3.12 a5 would fail with:
>
> mercurial/cext/dirs.c: In function '_addpath':
> mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
> 19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
> | ^~
> mercurial/cext/dirs.c:97:25: note: in expansion of macro 'PYLONG_VALUE'
> 97 | PYLONG_VALUE(val) += 1;
> | ^~~~~~~~~~~~
> mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
> 19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
> | ^~
> mercurial/cext/dirs.c:108:17: note: in expansion of macro 'PYLONG_VALUE'
> 108 | PYLONG_VALUE(val) = 1;
> | ^~~~~~~~~~~~
> mercurial/cext/dirs.c: In function '_delpath':
> mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
> 19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
> | ^~
> mercurial/cext/dirs.c:145:23: note: in expansion of macro 'PYLONG_VALUE'
> 145 | if (--PYLONG_VALUE(val) <= 0) {
> | ^~~~~~~~~~~~
>
> This was caused by
> https://github.com/python/cpython/commit/c1b1f51cd1632f0b77dacd43092fb44ed5e053a9 .
>
> diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
> --- a/mercurial/cext/dirs.c
> +++ b/mercurial/cext/dirs.c
> @@ -13,7 +13,11 @@
>
> #include "util.h"
>
> +#if PY_VERSION_HEX >= 0x030C00A5
> +#define PYLONG_VALUE(o) ((PyLongObject *)o)->long_value.ob_digit[0]
> +#else
> #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
> +#endif
>
> /*
> * This is a multiset of directory names, built from the files that
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at lists.mercurial-scm.org
> https://lists.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list