Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
These lines within python/rpmfd-py.c: rpmfdFromPyObject
are the wrong way around:
Py_DECREF(fdo);
PyErr_SetString(PyExc_IOError, Fstrerror(fdo->fd));
If fdo was allocated by the call above to PyObject_CallFunctionObjArgs,
it may have an ob_refcnt == 1, and thus the Py_DECREF() frees it, so
fdo->fd is reading from deallocated memory.
Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
|
|
- 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>
|
|
- 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>
|
|
- Similarly to python file object having o.name, export Fdescr()
as fd.name. Python uses <foo> for non-paths but [foo] seems like
a safer choice wrt accidental redirections.
- Also add a basic testcase for fd.name
|
|
- FD's are not really immutable, move the initialization work into
tp_init and use PyType_GenericNew for tp_new since we're not
doing anything special there.
- Remove half a dozen different unnecessary exit points
|
|
|
|
|
|
|
|
- Python 3 has fs-specific converter function, for Python 2 just
assume utf-8 and hope the best.
|
|
- cmpfunc is no more in Python 3 and casting NULL to anything makes
little sense anyhow
|
|
- this permits any file-like object implementing .fileno() method
(including rpm.fd) to be dup'ed, not just PyFile subtypes
- this also avoids yet another incompatibility with Python 3 which doesn't
have PyFile_Check() and PyFile_AsFile() at all
|
|
- 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
|
|
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
|
|
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.
|
|
|
|
- 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)
|
|
- attempt to mimic python file object where possible, but nowhere near
all methods are supported, either just not yet done or due to
underlying limitations
|
|
- permits direct validation and conversion from arg parsing
|
|
|
|
|
|
|
|
|
|
- adjust include paths accordingly
|
|
- add some helper macros to accomplish the same, easy to enable / disable
as needed
|
|
|
|
|
|
|
|
|
|
|
|
CVS patchset: 7582
CVS date: 2004/11/17 17:05:39
|
|
CVS patchset: 7082
CVS date: 2004/01/22 14:28:08
|
|
CVS patchset: 7055
CVS date: 2004/01/01 16:34:10
|
|
CVS patchset: 7051
CVS date: 2003/12/30 15:12:50
|
|
CVS patchset: 6961
CVS date: 2003/12/01 19:15:38
|
|
CVS patchset: 6959
CVS date: 2003/11/23 19:50:52
|
|
Convert to mpfprintlin from diddled mpprintln.
CVS patchset: 6811
CVS date: 2003/05/04 17:34:53
|
|
CVS patchset: 6807
CVS date: 2003/05/02 21:05:46
|
|
CVS patchset: 6760
CVS date: 2003/04/17 17:17:27
|
|
splint fiddles.
CVS patchset: 5933
CVS date: 2002/12/11 03:16:24
|
|
splint fiddles.
CVS patchset: 5932
CVS date: 2002/12/11 00:12:17
|
|
Use PyObject_{New,Del} consistently throughout.
CVS patchset: 5931
CVS date: 2002/12/10 19:46:03
|
|
CVS patchset: 5915
CVS date: 2002/12/04 02:01:47
|
|
CVS patchset: 5554
CVS date: 2002/07/14 21:23:29
|
|
Make sure that automake includes the python/test/* files.
CVS patchset: 5461
CVS date: 2002/06/03 23:27:05
|
|
CVS patchset: 5453
CVS date: 2002/05/28 23:06:44
|
|
- drop cpanflute and cpanflute2, will be in Chip's CPAN package now.
CVS patchset: 5452
CVS date: 2002/05/28 16:22:42
|
|
CVS patchset: 5451
CVS date: 2002/05/27 21:40:08
|