add-apt-repository crashed with ImportError in get_ppa_info_from_lp(): No module named 'pycurl'

Bug #1157900 reported by Thom Veldpaus
40
This bug affects 6 people
Affects Status Importance Assigned to Milestone
software-properties (Ubuntu)
Fix Released
High
Unassigned
Raring
Won't Fix
Medium
Unassigned

Bug Description

add-apt-repository crashed with ImportError in get_ppa_info_from_lp(): No module named 'pycurl'
i hope im helping, dont know anything about bugs myself

ProblemType: Crash
DistroRelease: Ubuntu 13.04
Package: software-properties-common 0.92.16
ProcVersionSignature: Ubuntu 3.8.0-12.8-lowlatency 3.8.2
Uname: Linux 3.8.0-12-lowlatency x86_64
ApportVersion: 2.9.2-0ubuntu2
Architecture: amd64
Date: Wed Mar 20 19:29:37 2013
ExecutablePath: /usr/bin/add-apt-repository
InstallationDate: Installed on 2013-03-19 (0 days ago)
InstallationMedia: Ubuntu-Studio 13.04 "Raring Ringtail" - Alpha amd64 (20130312)
InterpreterPath: /usr/bin/python3.3
MarkForUpload: True
PackageArchitecture: all
ProcCmdline: /usr/bin/python3 /usr/bin/add-apt-repository ppa:jd-team/jdownloade
PythonArgs: ['/usr/bin/add-apt-repository', 'ppa:jd-team/jdownloade']
SourcePackage: software-properties
Title: add-apt-repository crashed with ImportError in get_ppa_info_from_lp(): No module named 'pycurl'
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups:

Revision history for this message
Thom Veldpaus (iphoneveldpaus) wrote :
tags: removed: need-duplicate-check
Changed in software-properties (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Brian Murray (brian-murray) wrote :

It looks like software-properties is missing a dependency on python-pycurl or python3-pycurl.

Changed in software-properties (Ubuntu):
importance: Medium → High
status: New → Triaged
information type: Private → Public
Revision history for this message
Brian Murray (brian-murray) wrote :

Maybe also one on python-urllib. In add-apt-repository we see:

try:
    from urllib.error import HTTPError, URLError
except ImportError:
    import pycurl
    HTTPError = pycurl.error

Revision history for this message
Brian Murray (brian-murray) wrote :

I'm unable to recreate this at this point in time. Can you try this again and if it fails try the following in a terminal?

python3
import urllib

Thanks in advance!

Changed in software-properties (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
LeoRochael (leorochael) wrote :

The problem manifests itself in Python 2, not Python 3:

In Python3 we get:

vagrant@quantal64:/vagrant$ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import softwareproperties.ppa
>>>

In Python 2 we get:

vagrant@quantal64:/vagrant$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import softwareproperties.ppa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/softwareproperties/ppa.py", line 39, in <module>
    import pycurl
ImportError: No module named pycurl
>>>

After installing python-pycurl, the system works again:

vagrant@quantal64:/vagrant$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import softwareproperties.ppa
>>>

So yes, python-software-properties is missing a python-pycurl dependency except, perhaps, on ubuntu releases that make python3 the default python, in which case it's missing a python-pycurl "Recommends".

Changed in software-properties (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

While its true that this problem manifests itself with python2 add-apt-repository explicitly calls python3 and and the crash report indicates that the interpreter was python3.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

The real error here is that get_ppa_info_from_lp() has an “except:” line that catches all exceptions derived from BaseException, including KeyboardInterrupt and even SystemExit.

This is not recommended (see http://docs.python.org/3/howto/doanddont.html#except) and can lead to random bug errors like this one. I propose to change that line to “except NameError:” (which means that we failed to import urllib) or at least “except Exception:”.

Changed in software-properties (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Eliah Kagan (degeneracypressure) wrote :

This crash often happens to me when I terminate a running instance of add-apt-repository with Ctrl+C (though not every time, see duplicate bug 1186492 for details). I've been able to make that happen on multiple systems running different Ubuntu releases multiple times, so that might be a way for people who cannot reproduce the bug to do so.

Dmitry Shachnev's analysis (https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1157900/comments/7) clarifies why Ctrl+C is one way to produce the crash (get_ppa_info_from_lp() wrongly catches all exceptions including KeyboardInterrupt). Thanks for the explanation!

Revision history for this message
Brian Murray (brian-murray) wrote :

get_ppa_info_from_lp has changed a fair bit in saucy and subsequently does not have an "except:" line that catches all exceptions. However, this would still be good to fix in Raring.

Revision history for this message
Brian Murray (brian-murray) wrote :

Using NameError seems fine to me and I'm happy to help with getting that through the SRU process for Ubuntu 13.04. I found the test case in bug 1157900 helpful in recreating the bug.

Changed in software-properties (Ubuntu Raring):
importance: Undecided → Medium
status: New → Triaged
Changed in software-properties (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Rolf Leggewie (r0lf) wrote :

raring has seen the end of its life and is no longer receiving any updates. Marking the raring task for this ticket as "Won't Fix".

Changed in software-properties (Ubuntu Raring):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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