Oops, my last reply went directly to Michael instead of going to the BTS
as well.

My attached patch is what I'm now using on i386 and amd64 and it seems
to be working well  The debug output now looks like this:

# unattended-upgrade --debug
...
<apt_pkg.AcquireItem object: Status: 2 Complete: 1 Local: 1
IsTrusted: 1
DestFile:'/var/cache/apt/archives/python-apt_0.7.97.1_i386.deb'
DescURI:
'http://cdn.debian.net/debian/pool/main/p/python-apt/python-apt_0.7.97.1_i386.deb'
ID:0 ErrorText: '' FileSize: %llu>

As Michael just pointed out, the FileSize will show '%llu' in the debug output of Python 2.6 unless rewritten to use snprintf() or something.

Regards,
--
Steven Chamberlain
ste...@pyro.eu.org
--- python-apt-0.7.97.1~orig/python/acquire-item.cc	2010-05-19 11:48:44.000000000 +0100
+++ python-apt-0.7.97.1/python/acquire-item.cc	2010-09-24 21:36:33.000000000 +0100
@@ -65,7 +65,7 @@
 static PyObject *acquireitem_get_filesize(PyObject *self, void *closure)
 {
     pkgAcquire::Item *item = acquireitem_tocpp(self);
-    return item ? Py_BuildValue("i", item->FileSize) : 0;
+    return item ? Py_BuildValue("K", item->FileSize) : 0;
 }
 
 static PyObject *acquireitem_get_id(PyObject *self, void *closure)
@@ -95,7 +95,7 @@
 static PyObject *acquireitem_get_partialsize(PyObject *self, void *closure)
 {
     pkgAcquire::Item *item = acquireitem_tocpp(self);
-    return item ? Py_BuildValue("i", item->PartialSize) : 0;
+    return item ? Py_BuildValue("K", item->PartialSize) : 0;
 }
 
 static PyObject *acquireitem_get_status(PyObject *self, void *closure)
@@ -160,14 +160,17 @@
     pkgAcquire::Item *Itm = acquireitem_tocpp(Self);
     if (Itm == 0)
         return 0;
+    
+    // Display any 'long long' (eg. %llu) parameters last;  Python before 2.7
+    // will ignore these as well as any parameters after it.
     return PyString_FromFormat("<%s object: "
                                "Status: %i Complete: %i Local: %i IsTrusted: %i "
-                               "FileSize: %lu DestFile:'%s' "
-                               "DescURI: '%s' ID:%lu ErrorText: '%s'>",
+                               "DestFile:'%s' DescURI: '%s' "
+                               "ID:%lu ErrorText: '%s' FileSize: %llu>",
                                Self->ob_type->tp_name,
                                Itm->Status, Itm->Complete, Itm->Local, Itm->IsTrusted(),
-                               Itm->FileSize, Itm->DestFile.c_str(),  Itm->DescURI().c_str(),
-                               Itm->ID,Itm->ErrorText.c_str());
+                               Itm->DestFile.c_str(), Itm->DescURI().c_str(),
+                               Itm->ID, Itm->ErrorText.c_str(), Itm->FileSize);
 }
 
 static void acquireitem_dealloc(PyObject *self)

Reply via email to