From 7cc64d29ebf74c1e80f6e4f0e363aa114ff36890 Mon Sep 17 00:00:00 2001 From: C. Scott Ananian Date: Fri, 12 Sep 2008 04:31:35 +0000 Subject: Trac #8438: python -OO fails in control panel. There are two places in control panel code where we manipulate __doc__ strings directly with '+='. When python is run with -OO, the __doc__ strings are None, and so += of None and a str fails. --- diff --git a/src/controlpanel/model/datetime.py b/src/controlpanel/model/datetime.py index a449fd0..4a4c560 100644 --- a/src/controlpanel/model/datetime.py +++ b/src/controlpanel/model/datetime.py @@ -29,6 +29,10 @@ _zone_tab = '/usr/share/zoneinfo/zone.tab' def _initialize(): '''Initialize the docstring of the set function''' + if set_timezone.__doc__ is None: + # when running under 'python -OO', all __doc__ fields are None, + # so += would fail -- and this function would be unnecessary anyway. + return timezones = read_all_timezones() for timezone in timezones: set_timezone.__doc__ += timezone + '\n' diff --git a/src/controlpanel/model/language.py b/src/controlpanel/model/language.py index d835f77..404d9dd 100644 --- a/src/controlpanel/model/language.py +++ b/src/controlpanel/model/language.py @@ -53,6 +53,10 @@ def read_all_languages(): return locales def _initialize(): + if set_language.__doc__ is None: + # when running under 'python -OO', all __doc__ fields are None, + # so += would fail -- and this function would be unnecessary anyway. + return languages = read_all_languages() set_language.__doc__ += '\n' for lang in languages: -- cgit v0.9.1