summaryrefslogtreecommitdiff
path: root/python/apt_pkgmodule.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-04-13 19:13:25 +0200
committerJulian Andres Klode <jak@debian.org>2009-04-13 19:13:25 +0200
commit62d7f4b80d56ef1e27039441cd6584cfb71d6502 (patch)
treeaa2d006fccd4a4f8497eb25dc0bd6c8baf6e6e89 /python/apt_pkgmodule.cc
parenteaefd2f4cb97ed069375f18fb67d8570dc5eaed8 (diff)
downloadpython-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/apt_pkgmodule.cc')
-rw-r--r--python/apt_pkgmodule.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 1417e5d0..10d98911 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -184,10 +184,10 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args)
}
// Digest of a file
- if (PyFile_Check(Obj) != 0)
+ int Fd = PyObject_AsFileDescriptor(Obj);
+ if (Fd != -1)
{
MD5Summation Sum;
- int Fd = fileno(PyFile_AsFile(Obj));
struct stat St;
if (fstat(Fd,&St) != 0 ||
Sum.AddFD(Fd,St.st_size) == false)
@@ -224,10 +224,10 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args)
}
// Digest of a file
- if (PyFile_Check(Obj) != 0)
+ int Fd = PyObject_AsFileDescriptor(Obj);
+ if (Fd != -1)
{
SHA1Summation Sum;
- int Fd = fileno(PyFile_AsFile(Obj));
struct stat St;
if (fstat(Fd,&St) != 0 ||
Sum.AddFD(Fd,St.st_size) == false)
@@ -264,10 +264,10 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args)
}
// Digest of a file
- if (PyFile_Check(Obj) != 0)
+ int Fd = PyObject_AsFileDescriptor(Obj);
+ if (Fd != -1)
{
SHA256Summation Sum;
- int Fd = fileno(PyFile_AsFile(Obj));
struct stat St;
if (fstat(Fd,&St) != 0 ||
Sum.AddFD(Fd,St.st_size) == false)