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

#! /usr/bin/python{,3} -Es



I wanted to mention something that came up recently in Ubuntu, where
lsb_release is a Python 3 script.  This isn't specific to Python 3, since
Python 2 scripts can also be affected.

The Launchpad bug is symptomatic of the more general problem:

https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/938869

When you write system scripts like 'lsb_release' that use /usr/bin/python{,3}
in the #! line, please remember to include -Es switches.  This prevents the
crash in question, where a VMware installer script was mucking with
$PYTHONHOME for its own purposes, with the side effect of breaking Python's
search for its stdlib.  The bug notices it in lsb_release first, and we fixed
that in Ubuntu, but any other Python-based system script that the VMware
script would have called would also be broken.

This doesn't requires a mass freakout, but it might be useful for a mass bug
filing (of non-urgent priority, I think).  I don't have time before UDS-R to
look into that, so I at least wanted to send this email to put it on the
radar.  Here is what the switches do (from python -h):

-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE

Using -E fixed the immediate bug, but I think it is generally useful to
include -s also, so as to avoid any potential breakage of system scripts by
things users may have added locally.

Cheers,
-Barry

Attachment: signature.asc
Description: PGP signature


Reply to: