Commit Graph

100 Commits

Author SHA1 Message Date
Panu Matilainen 56c8977e18 Allow a shared pool with python rpmds and rpmfi objects
- Add an optional pool argument to python rpmds and rpmfi constructors
  to allow using a shared string pool from python too
2013-12-13 15:47:50 +02:00
Panu Matilainen 68a24e72b0 Use the pool-aware constructors for rpmfi and all rpmds types
- Doesn't actually change anything yet as pool is always NULL
2013-12-13 15:43:39 +02:00
Panu Matilainen a71a7981cc Revert the ds, ts, fi and spec python object creation commits
- Hasty push-finger syndrom, while its not exactly plain wrong to
  do things this way, it doesn't really make sense for these types
  either. Python's own file object permits reinitialization though,
  so leaving rpm.fd() the way it is now.
- This reverts the following commits:
  d056df28c3
  3f77c3146d
  7214b2e0a2
  dc50fb2863
2011-07-06 08:16:12 +03:00
Panu Matilainen d056df28c3 Fix/sanitize rpm.ds python object creation a bit
- Move all actual initialization work into tp_init, permit
  reinitialization without leaking and use PyType_GenericNew for tp_new.
2011-07-01 14:39:19 +03:00
Panu Matilainen 9c5eab023a Eww, python ds.Instance() doesn't take any arguments
- ...means its been broken all along, sigh
2011-06-09 14:25:37 +03:00
Panu Matilainen 99f9c67ad4 Python bindings dont need our debug.h for anything 2011-03-09 15:06:11 +02:00
Panu Matilainen ecead75632 Remove unused return code variable
- rpmdsRpmlib() can return errors but not really applicaple here
2011-03-04 13:49:16 +02:00
Panu Matilainen bf37b06d19 Permit comparison operator strings (<, >= etc) in python ds constructor
- Creating ('foo', '>=', '1.2') dependency is much nicer than
  or'ing rpm.RPMSENSE_FOO for flags. Allow (but validate) the string
  usage, ints get passed as is.
2010-12-16 17:12:12 +02:00
Panu Matilainen e8f777b69d Switch python bindings to use rpm(Dbi)TagVal as appropriate
- None of these are true enum uses as the value typically originates
  from python integers etc.
2010-10-22 11:57:38 +03:00
Panu Matilainen 0e0e332b46 Handle non-existent dependency sets in python (RhBug:593553)
- rpmdsNew() returns NULL if the requested dependency type doesn't
  exist in the header. The C-side API can handle NULL to all rpmds
  "methods" and this is how librpm deals with non-existent sets rather
  than waste memory on for empty ds structures. However the python side
  wasn't expecting NULL for legal requests (but not setting error either)
  and thus blowing up with SystemError exception.
- Raise TypeError on illegal arguments to rpm.ds constructor, and present
  non-existent dependency sets as empty rpm.ds objects to python. This
  lets python callers use iteration over ds items regardless of whether
  the dependency actually exists or not. The alternative of returning
  None (or raising exceptions) would break existing code for no
  particularly good reason.
2010-05-19 10:12:43 +03:00
Panu Matilainen 593902eee6 Remove unused dependency set file reference count
- this has never been used for anything at all, there are better things
  to use our memory for than unused arrays
2010-03-29 15:03:14 +03:00
Panu Matilainen e18d9e6826 Remove unused and non-sensible depedency set build-time
- Buildtime was never part of rpm version comparison nor should it be,
  on rpm level the only sensible differentiator between two identical
  dependencies is the dependency color if any. Other than that, random()
  just as "appropriate" as build time.
2010-03-29 14:53:10 +03:00
Panu Matilainen 8d3cad1d61 Add ds.Instance() method to python bindings
- the naming between header/rpmte/rpmds "instance" is wonderfully
  inconsistent... oh well
2010-03-26 17:11:13 +02:00
Panu Matilainen 01b047e759 Take advantage of rpmdsCurrent() in python bindings 2010-03-26 17:11:12 +02:00
Ville Skyttä e50e3d14e5 Document deprecation of mi.count() and ds.Count(). 2010-03-24 10:37:22 +02:00
Panu Matilainen 70bebfdd7e Eliminate ambiguous tp_compare and tp_richcompare from rpm.ds
- both comparison types are highly ambiguous, eg what on earth does
  "foo provides bar = 1" < "bar requires foo > 2" mean?
- if straight ds1.evr vs ds2.evr comparison is needed, we'll be better
  off supporting that through rpm.versionCompare() which has clear semantics
- avoids another Python 3 incompatibility too
2009-10-28 16:27:15 +02:00
Panu Matilainen 46b2df7c57 Add ds.Compare() as a thin wrapper over rpmdsCompare() 2009-10-28 16:25:46 +02:00
Panu Matilainen 1ce136261d Type-check rpm.ds() comparison/search arguments everywhere
- also make them only accept one argument, simplifying arg parsing
2009-10-28 16:24:16 +02:00
Panu Matilainen 615c45ec34 Rip out stillborn code 2009-10-28 16:17:21 +02:00
Panu Matilainen 714ebe92a1 Argh, typo in previous commit 2009-10-27 15:15:20 +02:00
Panu Matilainen 376b1bd8b7 Remove explicit Py_TPFLAGS_HAVE_RICHCOMPARE from ds type flags
- HAVE_RICHCOMPARE is included in Py_TPFLAGS_DEFAULT since at least
  Python 2.3 which is as far back as we care, no need to explicitly
  set it. Eliminating the unnecessary flag removes another Python 3
  compatibility issue as the flag is gone there.
2009-10-27 14:52:08 +02:00
David Malcolm 4b8e0ebde6 Generalize type object initialization to work with both Python 2.* and 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-19 11:02:13 +03:00
David Malcolm 7b51c4a1eb Generalize access to ob_type so that they work with both Python 2.* and 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-19 10:50:24 +03:00
Panu Matilainen dc6946e72e Revert explicit PyErr_NoMemory() returns to just returning NULL
- 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-09 11:57:46 +03:00
Panu Matilainen 3d1169fe69 Handle all rpmds variants in its constructor
- 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-05 16:42:52 +03:00
Panu Matilainen 9c88ea2c87 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
2009-10-01 15:12:06 +03:00
Panu Matilainen 8b704a6bf8 Oops, these are mappings, not dicts... 2009-10-01 14:55:55 +03:00
Panu Matilainen 909982b1b5 Deprecate custom foo.count() methods, support len() instead 2009-09-30 16:45:46 +03:00
Panu Matilainen b53f599596 Turn hdrGetHeader() into argument parsing converter interface 2009-09-30 12:11:43 +03:00
Panu Matilainen 2507ab6797 Enable subtyping on the rest of our type-objects
- not very useful atm as various places return hard-wired built-in types
2009-09-24 13:57:55 +03:00
Panu Matilainen df40d9b27b Eliminate all custom tp_free() type methods
- tp_free()'s purpose is only to free up the memory used by the python
  object structure, cleaning up our own allocations belongs to tp_dealloc()
2009-09-24 13:40:44 +03:00
Panu Matilainen 74c1040dbc Call (sub)type tp_free from destructors
- more preliminaries for subtyping
- remove pointless NULL checks
2009-09-24 12:52:32 +03:00
Panu Matilainen 36ada6c116 Make object allocation type agnostic
- pass (sub)type down to wrappers
- call subtype tp_alloc() instead of PyObject_New()
- preliminaries for allowing subtyping
2009-09-24 11:42:17 +03:00
Panu Matilainen 282efb6d4c Turn tagNumFromPyObject() into an object converter interface
- permits direct validation and conversion from arg parsing
2009-09-23 12:28:47 +03:00
Panu Matilainen c29492242c Remove tp_print methods from all rpm-python objects
- these violate the intended use of tp_print, python docs state
  "A type should never implement tp_print in a way that produces
  different output than tp_repr or tp_str would."
2009-09-23 10:44:41 +03:00
Panu Matilainen 6bbc19fb22 Lose the debug junk from python bindings 2009-09-23 10:39:40 +03:00
Panu Matilainen 39d79f9142 Rename python system.h for disambiguation 2009-09-22 23:02:47 +03:00
Panu Matilainen 14d5aaedcb Lose the empty doxygen markers
- nothing wrong with comments but empty comment placeholders
  are not exactly useful
2009-09-22 22:42:06 +03:00
Panu Matilainen 864220c441 Put some consistency to python object creation
- all type object creation goes through foo_Wrap() which handle OOM
  and all type specific initialization
2009-09-22 21:53:21 +03:00
Panu Matilainen ed557bbcf0 Make all python object creation wrappers return PyObject pointers
- this way the only place where casts are needed are in the wrapper itself
2009-09-22 21:24:55 +03:00
Panu Matilainen 4d6f8e46e0 Dont leak memory on rpm.ds iteration 2009-09-22 21:01:01 +03:00
Panu Matilainen 0cb5de3fc0 Lose unnecessary next() methods
- python adds next() methods for objects supporting iterators
2009-09-22 20:50:41 +03:00
Panu Matilainen 0793b2cf23 All rpm-python iterators are self-iterators, just use PyObject_SelfIter 2009-09-22 20:20:07 +03:00
Panu Matilainen d7134660ca Dont leak memory from rpm.dsSingle() 2009-09-22 19:55:34 +03:00
Panu Matilainen 708d4d8f1b Simplify dsFromHeader()
- just call the ds object, no need to manually redo all this stuff
2009-09-22 19:42:53 +03:00
Panu Matilainen da74188fa6 Sanitize python object -> tag number exception handling
- raise exception in tagNumFromPyObject(), not in 12 different callers
- check against RPMTAG_NOT_FOUND consistently instead of -1 and whatnot
- unknown tags are value, not key or type errors
2009-09-22 19:19:02 +03:00
Panu Matilainen 4c85c7e605 Move allocations out of rpmds object init method
- tp_init can be called several times, allocating from there leaks memory
- tp_init gets called automatically on object creation, dont call manually
2009-09-22 18:53:15 +03:00
Panu Matilainen 96a1b0a681 Use Py_RETURN_NONE macro for returning None everywhere 2009-09-22 17:49:53 +03:00
Panu Matilainen 43f585fced Eliminate unnecessary custom object allocation functions
- these are just calling python defaults, no point at all...
2009-09-22 17:33:07 +03:00
Panu Matilainen ca6591e86c Use generic python get/set attribute functions directly where appropriate
- no point in wrapping all this stuff in our own functions
2009-09-22 17:27:44 +03:00