~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/crash.py

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
17
"""Handling and reporting crashes.
19
18
 
20
19
A crash is an exception propagated up almost to the top level of Bazaar.
37
36
-Dno_apport.
38
37
"""
39
38
 
 
39
from __future__ import absolute_import
 
40
 
40
41
# for interactive testing, try the 'bzr assert-fail' command 
41
42
# or see http://code.launchpad.net/~mbp/bzr/bzr-fail
42
43
#
70
71
            return
71
72
    except ImportError, e:
72
73
        trace.mutter("couldn't find apport bug-reporting library: %s" % e)
73
 
        pass
74
74
    except Exception, e:
75
75
        # this should only happen if apport is installed but it didn't
76
76
        # work, eg because of an io error writing the crash file
77
 
        stderr.write("bzr: failed to report crash using apport:\n "
78
 
            "    %r\n" % e)
79
 
        pass
 
77
        trace.mutter("bzr: failed to report crash using apport: %r" % e)
 
78
        trace.log_exception_quietly()
80
79
    return report_bug_legacy(exc_info, stderr)
81
80
 
82
81
 
120
119
    # this function is based on apport_package_hook.py, but omitting some of the
121
120
    # Ubuntu-specific policy about what to report and when
122
121
 
123
 
    # if the import fails, the exception will be caught at a higher level and
124
 
    # we'll report the error by other means
 
122
    # This import is apparently not used, but we're doing it so that if the
 
123
    # import fails, the exception will be caught at a higher level and we'll
 
124
    # report the error by other means.
125
125
    import apport
126
126
 
127
127
    crash_filename = _write_apport_report_to_file(exc_info)
170
170
    pr['Platform'] = platform.platform(aliased=1)
171
171
    pr['UserEncoding'] = osutils.get_user_encoding()
172
172
    pr['FileSystemEncoding'] = sys.getfilesystemencoding()
173
 
    pr['Locale'] = os.environ.get('LANG')
 
173
    pr['Locale'] = os.environ.get('LANG', 'C')
174
174
    pr['BzrPlugins'] = _format_plugin_list()
175
175
    pr['PythonLoadedModules'] = _format_module_list()
176
176
    pr['BzrDebugFlags'] = pprint.pformat(debug.debug_flags)
259
259
        os.open(filename, 
260
260
            os.O_WRONLY|os.O_CREAT|os.O_EXCL,
261
261
            0600),
262
 
        'w')
 
262
        'wb')
263
263
 
264
264
 
265
265
def _format_plugin_list():