* [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
@ 2023-10-09 19:07 Bartosz Golaszewski
2023-10-09 20:59 ` Phil Howard
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-10-09 19:07 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Erik Schilling
Cc: linux-gpio, Bartosz Golaszewski, Phil Howard
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
to depend on python v3.9. Replace it with an older variant that steals the
reference to the added object on success.
Reported-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/python/gpiod/ext/module.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
index 25c252a..b456190 100644
--- a/bindings/python/gpiod/ext/module.c
+++ b/bindings/python/gpiod/ext/module.c
@@ -178,9 +178,9 @@ PyMODINIT_FUNC PyInit__ext(void)
return NULL;
}
- ret = PyModule_AddObjectRef(module, "__all__", all);
- Py_DECREF(all);
+ ret = PyModule_AddObject(module, "__all__", all);
if (ret) {
+ Py_DECREF(all);
Py_DECREF(module);
return NULL;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
2023-10-09 19:07 [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef() Bartosz Golaszewski
@ 2023-10-09 20:59 ` Phil Howard
2023-10-10 6:31 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Phil Howard @ 2023-10-09 20:59 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Erik Schilling, linux-gpio, Bartosz Golaszewski
On Mon, 9 Oct 2023 at 20:07, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
> to depend on python v3.9. Replace it with an older variant that steals the
> reference to the added object on success.
Ah, fixing this makes much more sense than bumping the dependent
version, thank you, I will update my patch.
>
> Reported-by: Phil Howard <phil@gadgetoid.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> bindings/python/gpiod/ext/module.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
> index 25c252a..b456190 100644
> --- a/bindings/python/gpiod/ext/module.c
> +++ b/bindings/python/gpiod/ext/module.c
> @@ -178,9 +178,9 @@ PyMODINIT_FUNC PyInit__ext(void)
> return NULL;
> }
>
> - ret = PyModule_AddObjectRef(module, "__all__", all);
> - Py_DECREF(all);
> + ret = PyModule_AddObject(module, "__all__", all);
> if (ret) {
> + Py_DECREF(all);
> Py_DECREF(module);
> return NULL;
> }
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
2023-10-09 20:59 ` Phil Howard
@ 2023-10-10 6:31 ` Bartosz Golaszewski
2023-10-10 9:50 ` Phil Howard
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-10-10 6:31 UTC (permalink / raw)
To: Phil Howard
Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Erik Schilling, linux-gpio, Bartosz Golaszewski
On Mon, Oct 9, 2023 at 11:00 PM Phil Howard <phil@gadgetoid.com> wrote:
>
> On Mon, 9 Oct 2023 at 20:07, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
> > to depend on python v3.9. Replace it with an older variant that steals the
> > reference to the added object on success.
>
> Ah, fixing this makes much more sense than bumping the dependent
> version, thank you, I will update my patch.
>
And of course the commit message was supposed to read: "bindings:
python: replace PyModule_AddObjectRef() with PyModule_AddObject()".
I'll fix it when applying.
Bart
> >
> > Reported-by: Phil Howard <phil@gadgetoid.com>
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> > bindings/python/gpiod/ext/module.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
> > index 25c252a..b456190 100644
> > --- a/bindings/python/gpiod/ext/module.c
> > +++ b/bindings/python/gpiod/ext/module.c
> > @@ -178,9 +178,9 @@ PyMODINIT_FUNC PyInit__ext(void)
> > return NULL;
> > }
> >
> > - ret = PyModule_AddObjectRef(module, "__all__", all);
> > - Py_DECREF(all);
> > + ret = PyModule_AddObject(module, "__all__", all);
> > if (ret) {
> > + Py_DECREF(all);
> > Py_DECREF(module);
> > return NULL;
> > }
> > --
> > 2.39.2
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
2023-10-10 6:31 ` Bartosz Golaszewski
@ 2023-10-10 9:50 ` Phil Howard
2023-10-10 10:01 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Phil Howard @ 2023-10-10 9:50 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Erik Schilling, linux-gpio, Bartosz Golaszewski
On Tue, 10 Oct 2023 at 07:31, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Mon, Oct 9, 2023 at 11:00 PM Phil Howard <phil@gadgetoid.com> wrote:
> >
> > On Mon, 9 Oct 2023 at 20:07, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > >
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
> > > to depend on python v3.9. Replace it with an older variant that steals the
I've done some digging and it looks like "PyModule_AddType" [1] helper
function is what's
anchoring the library to Python 3.9 (in the stable ABI as of 3.10)
rather than 3.8.
Is that correct? If so I'll update my patch to reflect the use of
PyModule_AddType.
The raw Python part of the library is compatible back to 3.7 (EOL),
3.8 EOL is this time next year so going < 3.9 is probably not worth the effort.
1. https://github.com/python/cpython/blob/43a6e4fa4934fcc0cbd83f7f3dc1b23a5f79f24b/Python/modsupport.c#L686-L703
> > > reference to the added object on success.
> >
> > Ah, fixing this makes much more sense than bumping the dependent
> > version, thank you, I will update my patch.
> >
>
> And of course the commit message was supposed to read: "bindings:
> python: replace PyModule_AddObjectRef() with PyModule_AddObject()".
>
> I'll fix it when applying.
>
> Bart
>
> > >
> > > Reported-by: Phil Howard <phil@gadgetoid.com>
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > ---
> > > bindings/python/gpiod/ext/module.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
> > > index 25c252a..b456190 100644
> > > --- a/bindings/python/gpiod/ext/module.c
> > > +++ b/bindings/python/gpiod/ext/module.c
> > > @@ -178,9 +178,9 @@ PyMODINIT_FUNC PyInit__ext(void)
> > > return NULL;
> > > }
> > >
> > > - ret = PyModule_AddObjectRef(module, "__all__", all);
> > > - Py_DECREF(all);
> > > + ret = PyModule_AddObject(module, "__all__", all);
> > > if (ret) {
> > > + Py_DECREF(all);
> > > Py_DECREF(module);
> > > return NULL;
> > > }
> > > --
> > > 2.39.2
> > >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
2023-10-10 9:50 ` Phil Howard
@ 2023-10-10 10:01 ` Bartosz Golaszewski
0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-10-10 10:01 UTC (permalink / raw)
To: Phil Howard
Cc: Bartosz Golaszewski, Kent Gibson, Linus Walleij, Andy Shevchenko,
Viresh Kumar, Erik Schilling, linux-gpio
On Tue, 10 Oct 2023 at 11:50, Phil Howard <phil@gadgetoid.com> wrote:
>
> On Tue, 10 Oct 2023 at 07:31, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > On Mon, Oct 9, 2023 at 11:00 PM Phil Howard <phil@gadgetoid.com> wrote:
> > >
> > > On Mon, 9 Oct 2023 at 20:07, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > >
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > >
> > > > PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
> > > > to depend on python v3.9. Replace it with an older variant that steals the
>
> I've done some digging and it looks like "PyModule_AddType" [1] helper
> function is what's
> anchoring the library to Python 3.9 (in the stable ABI as of 3.10)
> rather than 3.8.
>
> Is that correct? If so I'll update my patch to reflect the use of
> PyModule_AddType.
>
> The raw Python part of the library is compatible back to 3.7 (EOL),
> 3.8 EOL is this time next year so going < 3.9 is probably not worth the effort.
>
Agreed, and most distros ship >=v3.9 anyway.
Bart
> 1. https://github.com/python/cpython/blob/43a6e4fa4934fcc0cbd83f7f3dc1b23a5f79f24b/Python/modsupport.c#L686-L703
>
> > > > reference to the added object on success.
> > >
> > > Ah, fixing this makes much more sense than bumping the dependent
> > > version, thank you, I will update my patch.
> > >
> >
> > And of course the commit message was supposed to read: "bindings:
> > python: replace PyModule_AddObjectRef() with PyModule_AddObject()".
> >
> > I'll fix it when applying.
> >
> > Bart
> >
> > > >
> > > > Reported-by: Phil Howard <phil@gadgetoid.com>
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > > ---
> > > > bindings/python/gpiod/ext/module.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/bindings/python/gpiod/ext/module.c b/bindings/python/gpiod/ext/module.c
> > > > index 25c252a..b456190 100644
> > > > --- a/bindings/python/gpiod/ext/module.c
> > > > +++ b/bindings/python/gpiod/ext/module.c
> > > > @@ -178,9 +178,9 @@ PyMODINIT_FUNC PyInit__ext(void)
> > > > return NULL;
> > > > }
> > > >
> > > > - ret = PyModule_AddObjectRef(module, "__all__", all);
> > > > - Py_DECREF(all);
> > > > + ret = PyModule_AddObject(module, "__all__", all);
> > > > if (ret) {
> > > > + Py_DECREF(all);
> > > > Py_DECREF(module);
> > > > return NULL;
> > > > }
> > > > --
> > > > 2.39.2
> > > >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-10 10:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 19:07 [libgpiod][PATCH] bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef() Bartosz Golaszewski
2023-10-09 20:59 ` Phil Howard
2023-10-10 6:31 ` Bartosz Golaszewski
2023-10-10 9:50 ` Phil Howard
2023-10-10 10:01 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).