bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
PATCH 1/1 bindings: python: replace PyModule_AddObjectRef() with PyModule_AddObjectRef()
From: Bartosz Golaszewski <[email protected]>
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.
--- bindings/python/gpiod/ext/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
bindings/python/gpiod/ext/module.c +2 -2
@@ -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 ; }
Signature · 1 line
2.39.2
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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.
Quoted 26 lines
Reported-by Phil Howard <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- bindings/python/gpiod/ext/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)bindings/python/gpiod/ext/module.c +2
-3@@ -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
Quoted 12 lines · Phil Howard
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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
Quoted 26 lines
Quoted 26 lines
Reported-by Phil Howard <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- bindings/python/gpiod/ext/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)bindings/python/gpiod/ext/module.c +2
-3@@ -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
Quoted 9 lines · Bartosz Golaszewski
Quoted 7 lines · Phil Howard
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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.
Quoted 39 lines
Quoted 5 lines
Quoted 1 line
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: replacePyModule_AddObjectRef()withPyModule_AddObject()".I'll fix it when applying.
Bart
Quoted 26 lines
Quoted 26 lines
Reported-by Phil Howard <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- bindings/python/gpiod/ext/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)bindings/python/gpiod/ext/module.c +2
-3@@ -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
Quoted 17 lines · Phil Howard
Quoted 9 lines · Bartosz Golaszewski
Quoted 7 lines · Phil Howard
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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 theI'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.
Quoted 6 lines
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
Quoted 41 lines
Quoted 39 lines
Quoted 5 lines
Quoted 1 line
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: replacePyModule_AddObjectRef()withPyModule_AddObject()".I'll fix it when applying.
Bart
Quoted 26 lines
Quoted 26 lines
Reported-by Phil Howard <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- bindings/python/gpiod/ext/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)bindings/python/gpiod/ext/module.c +2
-3@@ -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