[Rpm-maint] [PATCH 12/15] Use PyUnicode_ on Python 3 when setting up the various RPMTAG_ constants
Panu Matilainen
pmatilai at redhat.com
Tue Oct 27 09:23:26 UTC 2009
On Thu, 15 Oct 2009, David Malcolm wrote:
> Python 3 doesn't have a PyString_ anymore; use PyUnicode_ instead.
> ---
> python/rpmmodule.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/python/rpmmodule.c b/python/rpmmodule.c
> index 6a3f98a..e0aeddc 100644
> --- a/python/rpmmodule.c
> +++ b/python/rpmmodule.c
> @@ -191,7 +191,11 @@ static void addRpmTags(PyObject *module)
>
> PyModule_AddIntConstant(module, tagname, tagval);
> pyval = PyInt_FromLong(tagval);
> +#if PY_MAJOR_VERSION >= 3
> + pyname = PyUnicode_FromString(shortname);
> +#else
> pyname = PyString_FromString(shortname);
> +#endif
> PyDict_SetItem(dict, pyval, pyname);
> Py_DECREF(pyval);
> Py_DECREF(pyname);
I fixed this a bit differently by using Py_BuildValue("s", shortname)
instead to let python decide what sort of object it wants to create:
Python 3 creates unicode and older ones create string objects.
- Panu -
More information about the Rpm-maint
mailing list