diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-05-21 17:13:51 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-05-21 17:13:51 +0300 |
commit | c06d688a3929742691eae2eb49643b2bd1d013c1 (patch) | |
tree | 61e750dd74ff4407f9ea7abe1c7c7bb5ff83af92 /python/rpmmodule.c | |
parent | 2525d192304246d366e08974ccfabb6bfdfc5ff4 (diff) | |
download | rpm-c06d688a3929742691eae2eb49643b2bd1d013c1.tar.gz rpm-c06d688a3929742691eae2eb49643b2bd1d013c1.tar.bz2 rpm-c06d688a3929742691eae2eb49643b2bd1d013c1.zip |
Don't muck with rpmTagTable internals in python initialization
Diffstat (limited to 'python/rpmmodule.c')
-rw-r--r-- | python/rpmmodule.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 251898a2e..456724f0a 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -233,9 +233,7 @@ void init_rpm(void); /* XXX eliminate gcc warning */ */ void init_rpm(void) { - PyObject * d, *o, * tag = NULL, * dict; - int i; - PyObject * m; + PyObject * d, *o, *tag = NULL, *dict, *m; #if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */ if (PyType_Ready(&hdr_Type) < 0) return; @@ -320,15 +318,18 @@ void init_rpm(void) #endif dict = PyDict_New(); - - for (i = 0; i < rpmTagTableSize; i++) { - tag = PyInt_FromLong(rpmTagTable[i].val); - PyDict_SetItemString(d, (char *) rpmTagTable[i].name, tag); - Py_DECREF(tag); - PyDict_SetItem(dict, tag, o=PyString_FromString(rpmTagTable[i].name + 7)); - Py_DECREF(o); - } - + { const char *tname; + rpmtd names = rpmTagGetNames(1); + + while ((tname = rpmtdNextString(names))) { + tag = PyInt_FromLong(rpmTagGetValue(tname)); + PyDict_SetItemString(d, tname, tag); + Py_DECREF(tag); + o = PyString_FromString(tname + strlen("RPMTAG_")); + PyDict_SetItem(dict, tag, o); + Py_DECREF(o); + } + } PyDict_SetItemString(d, "tagnames", dict); Py_DECREF(dict); |