summaryrefslogtreecommitdiff
path: root/python/tar.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-04-15 20:29:30 +0200
committerJulian Andres Klode <jak@debian.org>2009-04-15 20:29:30 +0200
commit49c10e3b9f6760280761f1255f3182637ba0ac9e (patch)
tree611819fece2da28d796b184457fb413f1f7b497d /python/tar.cc
parent23d29169c30b2f05a0c2943832a7cf7288ff5802 (diff)
parentabc7c861e85265b0725aa82a51fe41f9183bc506 (diff)
downloadpython-apt-49c10e3b9f6760280761f1255f3182637ba0ac9e.tar.gz
python-apt (0.7.90) experimental; urgency=low
* Introduce support for Python 3 (Closes: #523645) * Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub} objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection()) * Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). * Add support for the Breaks fields * Only create Package objects when they are requested, do not keep them in a dict. Saves 10MB for 25,000 packages on my machine. * apt/package.py: Allow to set the candidate of a package (Closes: #523997) - Support assignments to the 'candidate' property of Package objects. - Initial patch by Sebastian Heinlein -- Julian Andres Klode <jak@debian.org> Wed, 15 Apr 2009 13:47:42 +0200
Diffstat (limited to 'python/tar.cc')
-rw-r--r--python/tar.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/python/tar.cc b/python/tar.cc
index e5aaee6f..217554c2 100644
--- a/python/tar.cc
+++ b/python/tar.cc
@@ -97,8 +97,7 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args)
PyObject *Function;
char *Comp;
- if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File,
- &Function,&Comp) == 0)
+ if (PyArg_ParseTuple(Args,"OOs",&File, &Function,&Comp) == 0)
return 0;
if (PyCallable_Check(Function) == 0)
@@ -109,7 +108,11 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args)
{
// Open the file and associate the tar
- FileFd Fd(fileno(PyFile_AsFile(File)),false);
+ int fileno = PyObject_AsFileDescriptor(File);
+ if (fileno == -1)
+ return 0;
+
+ FileFd Fd(fileno,false);
ExtractTar Tar(Fd,0xFFFFFFFF,Comp);
if (_error->PendingError() == true)
return HandleErrors();
@@ -139,8 +142,7 @@ PyObject *debExtract(PyObject *Self,PyObject *Args)
char *Chunk;
const char *Comp = "gzip";
- if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File,
- &Function,&Chunk) == 0)
+ if (PyArg_ParseTuple(Args,"OOs",&File,&Function,&Chunk) == 0)
return 0;
if (PyCallable_Check(Function) == 0)
@@ -149,10 +151,13 @@ PyObject *debExtract(PyObject *Self,PyObject *Args)
return 0;
}
+ int fileno = PyObject_AsFileDescriptor(File);
+ if (fileno == -1)
+ return 0;
{
// Open the file and associate the tar
// Open the file and associate the .deb
- FileFd Fd(fileno(PyFile_AsFile(File)),false);
+ FileFd Fd(fileno,false);
debDebFile Deb(Fd);
if (_error->PendingError() == true)
return HandleErrors();