Launchpadlib crashes if os.environ['HOME'] not set

Bug #690783 reported by Anthony Lenton on 2010-12-15
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Martin Packman

Bug Description

If os.environ['HOME'] isn't set, Launchpadlib's login_anonymously fails:

anthony@atenea:~$ unset HOME
anthony@atenea:/home/anthony$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from launchpadlib.launchpad import Launchpad
>>> Launchpad.login_anonymously('some consumer', '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/launchpadlib/", line 225, in login_anonymously
    service_root_dir) = cls._get_paths(service_root, launchpadlib_dir)
  File "/usr/lib/pymodules/python2.6/launchpadlib/", line 319, in _get_paths
    home_dir = os.environ['HOME']
  File "/usr/lib/python2.6/", line 22, in __getitem__
    raise KeyError(key)
KeyError: 'HOME'

This bites you when deploying in environments that don't ensure os.environ['HOME'] is set, as with Apache + modwsgi.

Related branches

Robert Collins (lifeless) wrote :

Hi there, using mod_wsgi or the like is very unsafe - see bug 459418 : we really want single-threaded environments for launchpadlib today. I'd love a concurrent environment or a cacheless variant :)

Changed in launchpadlib:
status: New → Triaged
importance: Undecided → Low
Robert Collins (lifeless) wrote :

What you should do is setup a cache per thread, which will workaround this anyhow.

Martin Packman (gz) wrote :

Also the case on windows machines which may have HOMEDRIVE and HOMEPATH instead. Without any kind of home, raising an error seems like the right thing, but it should be a useful one that hints at the right fix.

Changed in launchpadlib:
assignee: nobody → Martin [gz] (gz)
Martin Packman (gz) on 2011-05-25
Changed in launchpadlib:
status: Triaged → In Progress
Martin Packman (gz) on 2011-10-04
Changed in launchpadlib:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers