Calling InitSystem() or InitConfig() raises AttributeError

Bug #1216655 reported by Tyler Hicks
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Invalid
High
Unassigned

Bug Description

Starting with python-apt 0.8.9.1ubuntu1 in Saucy, calling InitSystem() and InitConfig() fails:

$ python -c 'import apt_pkg; apt_pkg.InitSystem();'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'InitSystem'

Downgrading to 0.8.8.2ubuntu1 results in the expected behavior:

$ python -c 'import apt_pkg; apt_pkg.InitSystem();'
$ echo $?
0

Revision history for this message
Julian Andres Klode (juliank) wrote :

Does anything in Ubuntu still use those interfaces that were deprecated in 2010 and disabled in Debian in 2011? You should not.

Revision history for this message
Julian Andres Klode (juliank) wrote :

To be precise: Those interfaces were deprecated in 0.7.100; and I disabled them in Debian in the 0.8.0 upload.

Revision history for this message
Tyler Hicks (tyhicks) wrote :

I'm not sure if anything important in Ubuntu still uses those interfaces. The regression test suite (lp:qa-regression-testing) used by the Ubuntu Security team does, which caused unexpected test failures. I didn't see a mention in the changelog of these interfaces being removed, so thought it would be best to file a bug.

I'll be happy to convert our test suite over to the new interfaces and mark this bug as invalid. It looks like InitSystem() turned into init_system() and InitConfig() turned into init_config(), correct?

Revision history for this message
Julian Andres Klode (juliank) wrote :

Not only InitSystem and InitConfig were replaced. Everything was converted to PEP-8-style names, and all apt_pkg.Get*() were converted to classes. There is a tool at /usr/share/python-apt/migrate-0.8.py that finds problems (It might produce false positives, but should find everything that needs to be ported).

The short porting guide is at:

  http://apt.alioth.debian.org/python-apt-doc/whatsnew/0.7.100.html#porting-your-applications-to-the-new-python-apt-api

and the table of old Get*() functions and the classes that replace them is at:

  http://apt.alioth.debian.org/python-apt-doc/whatsnew/0.7.100.html#real-classes-in-apt-pkg

You can also find this document in a local installation of python-apt-doc.

Revision history for this message
Julian Andres Klode (juliank) wrote :

For the regression test suite, the attached patch should be enough.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "qa-regression-testing-python-apt-api.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
tags: removed: patch
Revision history for this message
Tyler Hicks (tyhicks) wrote :

Thanks for the patch, Julian!

I'm marking this bug as invalid since our tools were using deprecated apt_pkg interfaces.

Changed in python-apt (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.