summaryrefslogtreecommitdiff
path: root/python/header-py.c
AgeCommit message (Collapse)AuthorFilesLines
2021-01-05upgrade rpm version to 4.14.1upstream/4.14.1.1submit/tizen_base/20210113.025730submit/tizen_base/20210105.160930accepted/tizen/base/tool/20210118.215949biao716.wang1-40/+73
Change-Id: Iab5438d6e4d45c937b191c03e9ef5dd3fad165c8 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
2012-02-21Raise exception in python on headerGet() invalid data failurePanu Matilainen1-2/+6
2011-12-22mark strings extracted from PyArg_Parse* as "const"David Malcolm1-2/+2
- Various places within the bindings use PyArg_ParseTuple[AndKeywords] to extract (char*) string arguments. These are pointers to the internal representation of a PyStringObject, and shouldn't be modified, hence it's safest to explicitly mark these values as (const char*), rather than just (char*). Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-12-21typo in header-py.c.Ales Kozumplik1-1/+1
2011-12-21handle errors when constructing lists in the Python bindingsDavid Malcolm1-2/+13
- Various functions in the Python bindings construct lists of objects, but assume that all calls succeed. Each of these could segfault under low-memory conditions: if the PyList_New() call fails, PyList_Append(NULL, item ) will segfault. Similarly, although Py_List_Append(list, NULL) is safe, Py_DECREF(NULL) will segfault. Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-12-21fix memory leaks in invocations of PyObject_CallDavid Malcolm1-6/+5
- Various functions in the Python bindings have expressions of the form: PyObject_Call(callable, Py_BuildValue(fmtstring, ...), NULL); This leaks memory for the case when Py_BuildValue succeeds (it returns a new reference, which is never freed; PyObject_Call doesn't steal the reference): the argument tuple and all of its components will not be freed (until the process exits). Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-11-30Update internal callers to use headerExport(), no functional changesPanu Matilainen1-3/+2
2011-11-18python: use the more modern PyCapsule over PyCObject (RhBug:623864).Ales Kozumplik1-2/+2
- rpm.header.new() will still keep accepting PyCObject for now in case a client library depends on this. - involves macro trickery to make rpm buildable against python 2.6 still.
2011-09-01Avoid SystemError on inserting an empty list insert to header from pythonPanu Matilainen1-0/+2
2011-07-06Fix the broken python header __getattr__() behavior, take 13 (or so)Panu Matilainen1-1/+9
- Tags as header attributes seemed like a nice idea at the time... but has been a PITA due to side-effects it causes, such as breaking getattr() use for "capability testing", eg: >>> h2 = copy.deepcopy(h) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.7/copy.py", line 172, in deepcopy copier = getattr(x, "__deepcopy__", None) ValueError: unknown header tag - Since we can't really go removing the brainded feature (somebody might actually be using it) try harder to fix it: if its not an actual attribute, save the exception we got from PyObject_GenericGetAttr() and if its not a valid tag either, restore the original exception. This allows cases like the above __deepcopy__ to work properly.
2011-07-06Add __reduce__() method to python header objectPanu Matilainen1-15/+32
- This allows header objects to be pickled and also copied correctly with python's copy.copy() - Split the header to string-conversion into a separate helper function, used by the now largely unnecessary unload() method and __reduce__().
2011-03-09Eliminate unnecessary _free() usages in pythonPanu Matilainen1-2/+2
2011-03-09Python bindings dont need our debug.h for anythingPanu Matilainen1-2/+0
2010-11-17Avoid enum as function argument for headerConvert()Panu Matilainen1-1/+1
- While this /nearly/ qualifies for enum, places like python argument converting will not be able to produce "true enum" values. So dont even try.
2010-10-22Switch python bindings to use rpm(Dbi)TagVal as appropriatePanu Matilainen1-14/+14
- None of these are true enum uses as the value typically originates from python integers etc.
2010-09-22Use HEADER_MAGIC_FOO enums instead of 0/1 in python header codePanu Matilainen1-2/+2
2010-09-21Avoid stepping on toes of relatives, part 2Panu Matilainen1-5/+5
- Eliminate uses of "class" which is a reserved keyword in C++
2010-09-21Use the new tag type/return type getters everywherePanu Matilainen1-6/+5
- Instead of masking and bitfiddling all over the place, use the new getters to get the exact (enum) type directly. rpmTagGetType() is now unused within rpm but leaving around for backwards compatibility
2009-12-09Fix a few list-related memleaks in python bindingsPanu Matilainen1-1/+3
- PyList_Append() bumps the object reference count, callers need to explicitly decref them... oops :)
2009-12-07Make python header iterator return keys, not valuesPanu Matilainen1-3/+1
- this is how python built-in dictionary works, be consistent with that - also avoids having to decide what to do with rpm.td type right now...
2009-11-27Correctly pass optional tag argument from hdr.dsFromHeader() (ticket #108)Panu Matilainen1-2/+9
2009-11-27Dont try to pass anything to rpm.fi() from hdr.fiFromHeader()Panu Matilainen1-2/+5
- hdr.fiFromHeader() is just a deprecated backwards compatibility dummy and doesn't need to pass anything as there were no meaningful parameters in older versions
2009-11-24Nuke leftover debug junkPanu Matilainen1-1/+0
2009-11-24Support constructing header data from pythonPanu Matilainen1-4/+121
- no proper i18n string support yet, just the basic types - basic data type validation only, no overflow checking for integer types - for lists, validate all items before trying to insert anything - duplicate tag creation not permitted - appending not permitted, only assignment (and deletion already) - there are probably bugs... - watch out for librpm bugs when passed incomplete headers, ugh
2009-11-23Fix hdrContains() return value on errorPanu Matilainen1-1/+1
2009-11-21Remove hdr.has_key() method, support 'key in h' style insteadPanu Matilainen1-5/+16
- Python 3 removed has_key() from dictionaries, as the 'in' way is the way of the future support that from the start (has_key() is not in any released rpm version so its safe to remove)
2009-11-21Remove unnecessary hdr.instance() methodPanu Matilainen1-7/+0
- this is available through tag extension now, no point having a separate method for it
2009-11-19Permit header object generation from PyCObjectsPanu Matilainen1-0/+2
- needed for generating header objects from other extension modules & might be handy in some other cases too - patently type-unsafe but as long as python doesn't provide a better way, not really our headache
2009-10-28Eliminate the ambigious tp_compare from rpm.hdrPanu Matilainen1-7/+2
- Avoids another Python 3 incompatibility as it doesn't have tp_compare anymore - We could add a compatible tp_richcompare, but comparisons like 'if h1 < h2: do foo' are highly ambiguous, callers are better of using explicit rpm.versinCompare(h1, h2) instead
2009-10-23Allow unicode objects as tag name everywherePanu Matilainen1-2/+4
2009-10-23Add conversion function for handling python unicode -> string issuesPanu Matilainen1-0/+15
- In Python 3 everything is unicode, forcing each and every caller to convert manually is a bit much.
2009-10-21Replace PyString usage with PyBytes everywherePanu Matilainen1-5/+5
- In Python 2.6 PyBytes is just an alias for PyString, Python 3.0 removed PyString entirely - Add compatibility defines for Python < 2.6 - Based on David Malcolm's Python 3.x efforts
2009-10-19Remove leftovers from python header filesPanu Matilainen1-1/+1
- rpmSingleHeaderFromFD() and hdrLoad() are now implemented in python, declarations accidentally left here - make rpmMergeHeaders() static, nothing outside header-py.c needs
2009-10-19Generalize type object initialization to work with both Python 2.* and ↵David Malcolm1-2/+1
Python 3.* The layout of PyVarObject changed between python 2 and python 3, and this leads to the existing code for all of the various PyTypeObject initializers failing to compile with python 3 Change the way we initialize these structs to use PyVarObject_HEAD_INIT directly, rather than merely PyObject_HEAD_INIT, so that it compiles cleanly with both major versions of Python
2009-10-19Generalize access to ob_type so that they work with both Python 2.* and ↵David Malcolm1-1/+1
Python 3.* Python 2's various object structs use macros to implement common fields at the top of each struct. Python 3's objects instead embed a PyObject struct as the first member within the more refined object structs. Use the Py_TYPE() macro when accessing ob_type in order to encapsulate this difference.
2009-10-15Accept rpm.fd() types file objects everywhere in python bindingsPanu Matilainen1-8/+9
- turn rpmfdFromPyObject() into a python-level object converter, add a separate C-level getter for the fd pointer itself - take advantage of python refcounting to handle differences between native vs converted rpm.fd in callers so we can simply decref the rpmfdFromPyObject() result without having to worry whether it was converted or not (ie should we close it or not)
2009-10-12Raise exception in the converter, not callerPanu Matilainen1-1/+0
2009-10-12Add limited support for modifying headers to pythonPanu Matilainen1-1/+19
- for now we only support tag deletion and assigning rpmtd objects, limiting this to copying data from other headers
2009-10-09Revert explicit PyErr_NoMemory() returns to just returning NULLPanu Matilainen1-1/+1
- tp_alloc failing is likely to be OOM but we dont know that for a fact, and the failing method is responsible for setting the exception
2009-10-05Handle all rpmds variants in its constructorPanu Matilainen1-1/+14
- either it takes a header + tag, or (name, flags, version) tuple + tag to generate a single dep - push rpm.dsSingle() compatibility out to python side - hdr.dsFromHeader() and hdr.dsOfHeader() no longer need to be in rpmds-py.c
2009-10-01Add python method for retrieving header "instance" (db recno) numberPanu Matilainen1-0/+7
2009-10-01Deprecation tweaksPanu Matilainen1-11/+5
- 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
2009-10-01Fix couple of recently introduced compiler warningsPanu Matilainen1-1/+1
2009-09-30Take advantage of headerNextTag() in python hdr.keys()Panu Matilainen1-29/+6
- avoids whole lotta unnecessary copying of data, we're only interested in tag numbers here - dont filter out stuff - python consumers can look at i18n data too
2009-09-30Add iterator support to python header objectsPanu Matilainen1-3/+21
2009-09-30Turn hdrGetHeader() into argument parsing converter interfacePanu Matilainen1-3/+9
2009-09-30Sanitize getattr behavior of header objectsPanu Matilainen1-12/+20
- when generic getattr fails, only try retrieving header tag as attribute if it's a valid tag - clear any python errors if generic getattr failed - split generating a python object from header + tag to an internal helper
2009-09-28Implement rpm.readHeaderFromFD() in python instead of CPanu Matilainen1-44/+0
2009-09-28Implement rpm.readHeaderListFromFD() in python instead of CPanu Matilainen1-52/+0
2009-09-28Implement rpmreadHeaderListFromFile() in python instead of CPanu Matilainen1-23/+0