[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#571601: python-apt: unexpected behaviour of TagFile.offset TagFile.jump skips sections



Package: python-apt
Version: 0.7.93.1
Severity: normal

Hi,
while investigating #571470 (which shows similar symptoms but different
results) I incurred into an unexpected behavior of TagFile.offset and
TagFile.jump, specifically one would expect that after jump reading back the
offset would yield the same offset being jumped to, instead it seems to return
the next section (and not always). I used the attached test, running it on a
Packages file (any will do it seems, one from sid for example):

$ python aptpkg_bug.py  test_Packages
new parser offset 0, jumping to 833
after jump offset 1832
new parser offset 0, jumping to 2734
after jump offset 3557
new parser offset 0, jumping to 4529
after jump offset 5282
new parser offset 0, jumping to 6020
after jump offset 6922
new parser offset 0, jumping to 7772
after jump offset 8714
new parser offset 0, jumping to 10516
after jump offset 11545
new parser offset 0, jumping to 12349
after jump offset 13046
new parser offset 0, jumping to 14004
after jump offset 15118
new parser offset 0, jumping to 15938
after jump offset 16876
new parser offset 0, jumping to 17855
after jump offset 18741
new parser offset 0, jumping to 19700
after jump offset 20643
new parser offset 0, jumping to 21517
after jump offset 22371
new parser offset 0, jumping to 23203
after jump offset 24198
new parser offset 0, jumping to 25049
after jump offset 26480
new parser offset 0, jumping to 27689
after jump offset 28827
new parser offset 0, jumping to 30237
after jump offset 31029
new parser offset 0, jumping to 32018
after jump offset 33357
new parser offset 0, jumping to 34153
after jump offset 34153 equal
new parser offset 0, jumping to 35007
after jump offset 35007 equal
new parser offset 0, jumping to 36429
after jump offset 36429 equal
new parser offset 0, jumping to 38115
after jump offset 38115 equal
new parser offset 0, jumping to 39123
after jump offset 39123 equal
new parser offset 0, jumping to 40157
after jump offset 40157 equal
new parser offset 0, jumping to 41155
after jump offset 41155 equal
new parser offset 0, jumping to 43250
after jump offset 43250 equal

of course the number of sections yielded is lower than the Packages file.
Is this documented/wanted/expected? Seems rather odd.

thanks,
filippo

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.33-rc8 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-apt depends on:
ii  apt [libapt-pkg-libc6.9-6-4. 0.7.25.3    Advanced front-end for dpkg
ii  apt-utils [libapt-inst-libc6 0.7.25.3    APT utility programs
ii  libc6                        2.10.2-6    Embedded GNU C Library: Shared lib
ii  libgcc1                      1:4.4.3-2   GCC support library
ii  libstdc++6                   4.4.3-2     The GNU Standard C++ Library v3
ii  python                       2.5.4-9     An interactive high-level object-o
ii  python-central               0.6.14+nmu2 register and build utility for Pyt

Versions of packages python-apt recommends:
ii  iso-codes                     3.13-1     ISO language, territory, currency,
ii  libjs-jquery                  1.4.1-1    JavaScript library for dynamic web
ii  lsb-release                   3.2-23     Linux Standard Base version report

Versions of packages python-apt suggests:
pn  python-apt-dbg                <none>     (no description available)
ii  python-gtk2                   2.16.0-2   Python bindings for the GTK+ widge
ii  python-vte                    1:0.22.5-2 Python bindings for the VTE widget

-- no debconf information
#!/usr/bin/python

import sys

import apt_pkg

fname = sys.argv[1]

parser = apt_pkg.TagFile(open(fname))
while parser.Step() == 1:

    offset = parser.Offset()
    parser = apt_pkg.TagFile(open(fname))
    print "new parser offset %s, jumping to %s" % (parser.Offset(), offset)
    parser.Jump(offset)
    if offset == parser.Offset():
        print "after jump offset %s equal" % parser.Offset()
    else:
        print "after jump offset %s" % parser.Offset()

Reply to: