diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-04-13 19:13:25 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-04-13 19:13:25 +0200 |
| commit | 62d7f4b80d56ef1e27039441cd6584cfb71d6502 (patch) | |
| tree | aa2d006fccd4a4f8497eb25dc0bd6c8baf6e6e89 /python/tag.cc | |
| parent | eaefd2f4cb97ed069375f18fb67d8570dc5eaed8 (diff) | |
| download | python-apt-62d7f4b80d56ef1e27039441cd6584cfb71d6502.tar.gz | |
* python/*.cc: Use PyObject_AsFileDescriptor instead of fileno(PyFile_AsFile)
Replace support for file objects with a more generic support for any object
providing a fileno() method and for file descriptors (integers).
This also helps us to port to Python 3, where the previously used PyFile_
functions are not available anymore.
Diffstat (limited to 'python/tag.cc')
| -rw-r--r-- | python/tag.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/python/tag.cc b/python/tag.cc index f3fb2e6c..baf97b59 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -272,11 +272,14 @@ char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile"; PyObject *ParseTagFile(PyObject *self,PyObject *Args) { PyObject *File; - if (PyArg_ParseTuple(Args,"O!",&PyFile_Type,&File) == 0) + if (PyArg_ParseTuple(Args,"O",&File) == 0) + return 0; + int fileno = PyObject_AsFileDescriptor(File); + if (fileno == -1) return 0; TagFileData *New = PyObject_NEW(TagFileData,&TagFileType); - new (&New->Fd) FileFd(fileno(PyFile_AsFile(File)),false); + new (&New->Fd) FileFd(fileno,false); New->File = File; Py_INCREF(New->File); new (&New->Object) pkgTagFile(&New->Fd); |
