diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-10-01 15:12:06 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-10-01 15:12:06 +0300 |
commit | 9c88ea2c87b5d22026400fb19f064b7967aa4743 (patch) | |
tree | 81f2870c718c744b12b149dd15befe13a144317f | |
parent | 8b704a6bf8ae2c5a922b54ff35c65525e93f0f1f (diff) | |
download | rpm-9c88ea2c87b5d22026400fb19f064b7967aa4743.tar.gz rpm-9c88ea2c87b5d22026400fb19f064b7967aa4743.tar.bz2 rpm-9c88ea2c87b5d22026400fb19f064b7967aa4743.zip |
Deprecation tweaks
- use PyErr_WarnEx() for better control and leave the tracking up to python
- use PendingDeprecationWarning for now
- document the replacing functionality in the deprecation messages
- make hdr.sprintf() just an alias to hdr.format() without deprecating,
at least for now it'd be only a gratuitous incompatible change on python side
-rw-r--r-- | python/header-py.c | 16 | ||||
-rw-r--r-- | python/header-py.h | 6 | ||||
-rw-r--r-- | python/rpmds-py.c | 2 | ||||
-rw-r--r-- | python/rpmmi-py.c | 2 | ||||
-rw-r--r-- | python/rpmts-py.c | 2 |
5 files changed, 10 insertions, 18 deletions
diff --git a/python/header-py.c b/python/header-py.c index 31d5edd72..008194073 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -180,7 +180,7 @@ static PyObject * hdrUnload(hdrObject * s, PyObject * args, PyObject *keywords) static PyObject * hdrExpandFilelist(hdrObject * s) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use hdr.convert() instead"); headerConvert(s->h, HEADERCONV_EXPANDFILELIST); Py_RETURN_NONE; @@ -188,7 +188,7 @@ static PyObject * hdrExpandFilelist(hdrObject * s) static PyObject * hdrCompressFilelist(hdrObject * s) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use hdr.convert() instead"); headerConvert(s->h, HEADERCONV_COMPRESSFILELIST); Py_RETURN_NONE; @@ -200,7 +200,7 @@ static PyObject * hdrFullFilelist(hdrObject * s) rpmtd fileNames = rpmtdNew(); Header h = s->h; - DEPRECATED_METHOD; + DEPRECATED_METHOD("obsolete method"); if (!headerIsEntry (h, RPMTAG_BASENAMES) || !headerIsEntry (h, RPMTAG_DIRNAMES) || !headerIsEntry (h, RPMTAG_DIRINDEXES)) @@ -239,12 +239,6 @@ static PyObject * hdrFormat(hdrObject * s, PyObject * args, PyObject * kwds) return result; } -static PyObject * hdrSprintf(hdrObject * s, PyObject * args, PyObject * kwds) -{ - DEPRECATED_METHOD; - return hdrFormat(s, args, kwds); -} - static PyObject *hdrIsSource(hdrObject *s) { return PyBool_FromLong(headerIsSource(s->h)); @@ -293,7 +287,7 @@ static PyObject * hdrWrite(hdrObject *s, PyObject *args, PyObject *kwds) static PyObject * hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwds) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use convert() instead"); return PyObject_Call((PyObject *) &rpmfi_Type, Py_BuildValue("(O)", s), kwds); } @@ -325,7 +319,7 @@ static struct PyMethodDef hdr_methods[] = { NULL }, {"has_key", (PyCFunction) hdrHasKey, METH_O, NULL }, - {"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS|METH_KEYWORDS, + {"sprintf", (PyCFunction) hdrFormat, METH_VARARGS|METH_KEYWORDS, NULL }, {"isSource", (PyCFunction)hdrIsSource, METH_NOARGS, NULL }, diff --git a/python/header-py.h b/python/header-py.h index ad16e013c..8c9dd6811 100644 --- a/python/header-py.h +++ b/python/header-py.h @@ -9,10 +9,8 @@ extern PyTypeObject hdr_Type; #define hdrObject_Check(v) ((v)->ob_type == &hdr_Type) -#define DEPRECATED_METHOD \ - static int _warn = 0; \ - if (!_warn) PyErr_Warn(PyExc_DeprecationWarning, "method is deprecated"); \ - _warn = 1; +#define DEPRECATED_METHOD(_msg) \ + PyErr_WarnEx(PyExc_PendingDeprecationWarning, (_msg), 2); extern PyObject * pyrpmError; diff --git a/python/rpmds-py.c b/python/rpmds-py.c index d4456e9d1..3818a9071 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -63,7 +63,7 @@ void rpmds_ParseEVR(char * evr, static PyObject * rpmds_Count(rpmdsObject * s) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use len(ds) instead"); return Py_BuildValue("i", PyMapping_Size((PyObject *)s)); } diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index e02389180..1d06b5ed9 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -93,7 +93,7 @@ rpmmi_Instance(rpmmiObject * s) static PyObject * rpmmi_Count(rpmmiObject * s) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use len(mi) instead"); return Py_BuildValue("i", PyMapping_Size((PyObject *)s)); } diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 82be3754e..3f440602d 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -781,7 +781,7 @@ rpmts_iternext(rpmtsObject * s) static PyObject * spec_Parse(rpmtsObject * s, PyObject * args, PyObject * kwds) { - DEPRECATED_METHOD; + DEPRECATED_METHOD("use 'spec = rpm.spec(<specfile>)' instead"); /* we could pass in the ts from here but hardly worth the trouble */ return PyObject_Call((PyObject *) &spec_Type, args, kwds); } |