PyObject_Del(s);
}
-/** \ingroup py_c
- */
rpmTag tagNumFromPyObject (PyObject *item)
{
- char * str;
+ rpmTag tag = RPMTAG_NOT_FOUND;
if (PyInt_Check(item)) {
- return PyInt_AsLong(item);
+ /* XXX we should probably validate tag numbers too */
+ tag = PyInt_AsLong(item);
} else if (PyString_Check(item)) {
- str = PyString_AsString(item);
- return rpmTagGetValue(str);
+ tag = rpmTagGetValue(PyString_AsString(item));
+ }
+ if (tag == RPMTAG_NOT_FOUND) {
+ PyErr_SetString(PyExc_ValueError, "unknown header tag");
}
- return RPMTAG_NOT_FOUND;
+
+ return tag;
}
/** \ingroup py_c
struct rpmtd_s td;
tag = tagNumFromPyObject (item);
- if (tag == RPMTAG_NOT_FOUND) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tag == RPMTAG_NOT_FOUND) return NULL;
tagtype = rpmTagGetType(tag);
forceArray = (tagtype & RPM_MASK_RETURN_TYPE) == RPM_ARRAY_RETURN_TYPE;
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
s->ds = rpmdsNew(hdrGetHeader(ho), tagN, 0);
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
if (N != NULL) N = xstrdup(N);
if (EVR != NULL) EVR = xstrdup(EVR);
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
return rpmds_Wrap( rpmdsNew(hdrGetHeader(ho), tagN, 0) );
}
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
s->fi = rpmfiNew(NULL, hdrGetHeader(ho), tagN, flags);
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
return rpmfi_Wrap( rpmfiNew(ts, hdrGetHeader(ho), tagN, flags) );
}
&TagN, &type, &pattern))
return NULL;
- if ((tag = tagNumFromPyObject (TagN)) == -1) {
- PyErr_SetString(PyExc_TypeError, "unknown tag type");
- return NULL;
- }
+ tag = tagNumFromPyObject (TagN);
+ if (tag == RPMTAG_NOT_FOUND) return NULL;
rpmdbSetIteratorRE(s->mi, tag, type, pattern);
return NULL;
tag = tagNumFromPyObject(TagN);
- if (tag == -1) {
- PyErr_SetString(PyExc_TypeError, "unknown tag type");
- return NULL;
- }
+ if (tag == RPMTAG_NOT_FOUND) return NULL;
ds = rpmteDS(s->te, tag);
if (ds == NULL) {
&TagN, &Key))
return NULL;
- if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) {
- PyErr_SetString(PyExc_TypeError, "unknown tag type");
+ if (TagN && (tag = tagNumFromPyObject (TagN)) == RPMTAG_NOT_FOUND) {
return NULL;
}