* [PATCH] pylibfdt: fix with Python 3.10
@ 2021-11-11 16:05 Ross Burton
[not found] ` <20211111160536.2516573-1-ross.burton-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Ross Burton @ 2021-11-11 16:05 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
Since Python 2.5 the argument parsing functions when parsing expressions
such as s# (string plus length) expect the length to be an int or a
ssize_t, depending on whether PY_SSIZE_T_CLEAN is defined or not.
Python 3.8 deprecated the use of int, and with Python 3.10 this symbol
must be defined and ssize_t used[1].
Define the magic symbol when building the extension, and cast the ints
from the libfdt API to ssize_t as appropriate.
[1] https://docs.python.org/3.10/whatsnew/3.10.html#id2
Signed-off-by: Ross Burton <ross.burton-5wv7dgnIgG8@public.gmane.org>
---
pylibfdt/libfdt.i | 4 ++--
pylibfdt/setup.py | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index 51ee801..075ef70 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t;
$result = Py_None;
else
%#if PY_VERSION_HEX >= 0x03000000
- $result = Py_BuildValue("y#", $1, *arg4);
+ $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
%#else
- $result = Py_BuildValue("s#", $1, *arg4);
+ $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
%#endif
}
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index ef40f15..81e161a 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -42,6 +42,7 @@ def get_version():
libfdt_module = Extension(
'_libfdt',
sources=[os.path.join(srcdir, 'libfdt.i')],
+ define_macros=[('PY_SSIZE_T_CLEAN', None)],
include_dirs=[os.path.join(srcdir, '../libfdt')],
libraries=['fdt'],
library_dirs=[os.path.join(top_builddir, 'libfdt')],
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] pylibfdt: fix with Python 3.10
[not found] ` <20211111160536.2516573-1-ross.burton-5wv7dgnIgG8@public.gmane.org>
@ 2021-11-11 21:58 ` Rob Herring
2021-11-12 1:46 ` David Gibson
1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2021-11-11 21:58 UTC (permalink / raw)
To: Ross Burton; +Cc: Devicetree Compiler
On Thu, Nov 11, 2021 at 10:05 AM Ross Burton <ross.burton-5wv7dgnIgG8@public.gmane.org> wrote:
>
> Since Python 2.5 the argument parsing functions when parsing expressions
> such as s# (string plus length) expect the length to be an int or a
> ssize_t, depending on whether PY_SSIZE_T_CLEAN is defined or not.
>
> Python 3.8 deprecated the use of int, and with Python 3.10 this symbol
> must be defined and ssize_t used[1].
>
> Define the magic symbol when building the extension, and cast the ints
> from the libfdt API to ssize_t as appropriate.
>
> [1] https://docs.python.org/3.10/whatsnew/3.10.html#id2
>
> Signed-off-by: Ross Burton <ross.burton-5wv7dgnIgG8@public.gmane.org>
> ---
> pylibfdt/libfdt.i | 4 ++--
> pylibfdt/setup.py | 1 +
setup.py just moved up a level.
With that fixed up,
Tested-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pylibfdt: fix with Python 3.10
[not found] ` <20211111160536.2516573-1-ross.burton-5wv7dgnIgG8@public.gmane.org>
2021-11-11 21:58 ` Rob Herring
@ 2021-11-12 1:46 ` David Gibson
1 sibling, 0 replies; 4+ messages in thread
From: David Gibson @ 2021-11-12 1:46 UTC (permalink / raw)
To: Ross Burton; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2110 bytes --]
On Thu, Nov 11, 2021 at 04:05:36PM +0000, Ross Burton wrote:
> Since Python 2.5 the argument parsing functions when parsing expressions
> such as s# (string plus length) expect the length to be an int or a
> ssize_t, depending on whether PY_SSIZE_T_CLEAN is defined or not.
>
> Python 3.8 deprecated the use of int, and with Python 3.10 this symbol
> must be defined and ssize_t used[1].
>
> Define the magic symbol when building the extension, and cast the ints
> from the libfdt API to ssize_t as appropriate.
>
> [1] https://docs.python.org/3.10/whatsnew/3.10.html#id2
>
> Signed-off-by: Ross Burton <ross.burton-5wv7dgnIgG8@public.gmane.org>
Applied (with the correct to the setup.py location). Thanks!
> ---
> pylibfdt/libfdt.i | 4 ++--
> pylibfdt/setup.py | 1 +
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> index 51ee801..075ef70 100644
> --- a/pylibfdt/libfdt.i
> +++ b/pylibfdt/libfdt.i
> @@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t;
> $result = Py_None;
> else
> %#if PY_VERSION_HEX >= 0x03000000
> - $result = Py_BuildValue("y#", $1, *arg4);
> + $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
> %#else
> - $result = Py_BuildValue("s#", $1, *arg4);
> + $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
> %#endif
> }
>
> diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
> index ef40f15..81e161a 100755
> --- a/pylibfdt/setup.py
> +++ b/pylibfdt/setup.py
> @@ -42,6 +42,7 @@ def get_version():
> libfdt_module = Extension(
> '_libfdt',
> sources=[os.path.join(srcdir, 'libfdt.i')],
> + define_macros=[('PY_SSIZE_T_CLEAN', None)],
> include_dirs=[os.path.join(srcdir, '../libfdt')],
> libraries=['fdt'],
> library_dirs=[os.path.join(top_builddir, 'libfdt')],
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] pylibfdt: fix with Python 3.10
@ 2021-11-11 15:45 Ross Burton
0 siblings, 0 replies; 4+ messages in thread
From: Ross Burton @ 2021-11-11 15:45 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
Since Python 2.5 the argument parsing functions when parsing expressions
such as s# (string plus length) expect the length to be an int or a
ssize_t, depending on whether PY_SSIZE_T_CLEAN is defined or not.
Python 3.8 deprecated the use of int, and with Python 3.10 this symbol
must be defined and ssize_t used[1].
Define the magic symbol when building the extension, and cast the ints
from the libfdt API to ssize_t as appropriate.
[1] https://docs.python.org/3.10/whatsnew/3.10.html#id2
Signed-off-by: Ross Burton <ross.burton-5wv7dgnIgG8@public.gmane.org>
---
pylibfdt/libfdt.i | 4 ++--
pylibfdt/setup.py | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index 51ee801..075ef70 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t;
$result = Py_None;
else
%#if PY_VERSION_HEX >= 0x03000000
- $result = Py_BuildValue("y#", $1, *arg4);
+ $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
%#else
- $result = Py_BuildValue("s#", $1, *arg4);
+ $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
%#endif
}
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index ef40f15..81e161a 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -42,6 +42,7 @@ def get_version():
libfdt_module = Extension(
'_libfdt',
sources=[os.path.join(srcdir, 'libfdt.i')],
+ define_macros=[('PY_SSIZE_T_CLEAN', None)],
include_dirs=[os.path.join(srcdir, '../libfdt')],
libraries=['fdt'],
library_dirs=[os.path.join(top_builddir, 'libfdt')],
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-12 1:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 16:05 [PATCH] pylibfdt: fix with Python 3.10 Ross Burton
[not found] ` <20211111160536.2516573-1-ross.burton-5wv7dgnIgG8@public.gmane.org>
2021-11-11 21:58 ` Rob Herring
2021-11-12 1:46 ` David Gibson
-- strict thread matches above, loose matches on Subject: below --
2021-11-11 15:45 Ross Burton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.