Crash when using GTK elements due to use of deprecated function

Bug #865388 reported by Tom Ellis on 2011-10-03
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
High
Unassigned
Oneiric
High
Unassigned

Bug Description

## Issue
 * python-apt crashes when using a gtk element.
 * Deprecated call from python-vte

## Environment

Ubuntu 11.10 x86_64
python-apt 0.8.0ubuntu8
python-vte 0.28.0ubuntu2

## Diagnostic steps

1. Using the example from: http://apt.alioth.debian.org/python-apt-doc/library/apt.progress.gtk2.html
2. Run example on an oneiric system

This worked fine in before Oneiric's version of python-apt but now fails:
Traceback (most recent call last):
  File "test.py", line 29, in <module>
    main()
  File "test.py", line 14, in main
    progress = apt.progress.gtk2.GtkAptProgress()
  File "/usr/lib/python2.7/dist-packages/apt/progress/gtk2.py", line 373, in __init__
    self._progress_install = GInstallProgress(self._terminal)
  File "/usr/lib/python2.7/dist-packages/apt/progress/gtk2.py", line 130, in __init__
    reaper = vte.reaper_get()
AttributeError: 'module' object has no attribute 'reaper_get'

## Workaround

* apply a small patch to gtk2.py

130,131c130,131
< reaper = vte.reaper_get()
< reaper.connect("child-exited", self.child_exited)
---
> self.terminal = vte.Terminal()
> self.terminal.connect("child-exited", self.child_exited)

* re-run test case

## Other info

A gnome app, 'OnTV' faced a similar issue with the function and fixed it with this patch:
http://mail.gnome.org/archives/commits-list/2011-February/msg00737.html

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: python-apt 0.8.0ubuntu8
ProcVersionSignature: Ubuntu 3.0.0-12.19-generic 3.0.4
Uname: Linux 3.0.0-12-generic x86_64
ApportVersion: 1.23-0ubuntu2
Architecture: amd64
Date: Mon Oct 3 15:09:11 2011
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Beta amd64 (20111003)
ProcEnviron:
 LANGUAGE=en_GB:en
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: python-apt
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Tom Ellis (tellis) wrote :
Tom Ellis (tellis) on 2011-10-03
description: updated
tags: added: customer-support pse
Tom Ellis (tellis) wrote :

After applying a small patch to gtk2.py, we can over come the issue:

130,131c130,131
< reaper = vte.reaper_get()
< reaper.connect("child-exited", self.child_exited)
---
> self.terminal = vte.Terminal()
> self.terminal.connect("child-exited", self.child_exited)

Tom Ellis (tellis) wrote :
Tom Ellis (tellis) on 2011-10-03
description: updated
Tom Ellis (tellis) wrote :

Attaching patch

Jonathan Davies (jpds) on 2011-10-03
Changed in python-apt (Ubuntu):
status: New → Confirmed

The attachment "lp865388.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Michael Vogt (mvo) on 2011-10-04
Changed in python-apt (Ubuntu):
status: Confirmed → In Progress
importance: Undecided → High
Michael Vogt (mvo) wrote :

The child-exited signal from vte has a different signature then the previous child-exited. So this will need a small tweak.

Michael Vogt (mvo) wrote :

Here is the diff:
=== modified file 'apt/progress/gtk2.py'
--- apt/progress/gtk2.py 2011-01-10 17:08:13 +0000
+++ apt/progress/gtk2.py 2011-10-04 14:36:48 +0000
@@ -34,6 +34,7 @@
     import gobject as glib
 import gobject
 import pango
+import time
 import vte

 import apt_pkg
@@ -127,16 +128,15 @@
         self.apt_status = -1
         self.time_last_update = time.time()
         self.term = term
- reaper = vte.reaper_get()
- reaper.connect("child-exited", self.child_exited)
+ self.term.connect("child-exited", self.child_exited)
         self.env = ["VTE_PTY_KEEP_FD=%s" % self.writefd,
                     "DEBIAN_FRONTEND=gnome",
                     "APT_LISTCHANGES_FRONTEND=gtk"]
         self._context = glib.main_context_default()

- def child_exited(self, term, pid, status):
+ def child_exited(self, term):
         """Called when a child process exits"""
- self.apt_status = os.WEXITSTATUS(status)
+ self.apt_status = term.get_child_exit_status()
         self.finished = True

     def error(self, pkg, errormsg):
@@ -204,6 +204,7 @@
         """Wait for the child process to exit."""
         while not self.finished:
             self.update_interface()
+ time.sleep(0.02)
         return self.apt_status

     if apt_pkg._COMPAT_0_7:

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-apt - 0.8.0ubuntu9

---------------
python-apt (0.8.0ubuntu9) oneiric; urgency=low

  * apt/progress/gtk2.py:
    - update to the latest vte API for child-exited (LP: #865388)
 -- Michael Vogt <email address hidden> Tue, 04 Oct 2011 16:35:52 +0200

Changed in python-apt (Ubuntu Oneiric):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers