Show More
@@ -18,6 +18,7 b' from .i18n import (' | |||||
18 |
|
18 | |||
19 | from . import ( |
|
19 | from . import ( | |
20 | cmdutil, |
|
20 | cmdutil, | |
|
21 | encoding, | |||
21 | error, |
|
22 | error, | |
22 | pycompat, |
|
23 | pycompat, | |
23 | util, |
|
24 | util, | |
@@ -104,11 +105,18 b' def _importext(name, path=None, reportfu' | |||||
104 | mod = _importh(name) |
|
105 | mod = _importh(name) | |
105 | return mod |
|
106 | return mod | |
106 |
|
107 | |||
|
108 | def _forbytes(inst): | |||
|
109 | """Portably format an import error into a form suitable for | |||
|
110 | %-formatting into bytestrings.""" | |||
|
111 | if pycompat.ispy3: | |||
|
112 | return encoding.tolocal(str(inst).encode('utf-8')) | |||
|
113 | return inst | |||
|
114 | ||||
107 | def _reportimporterror(ui, err, failed, next): |
|
115 | def _reportimporterror(ui, err, failed, next): | |
108 | # note: this ui.debug happens before --debug is processed, |
|
116 | # note: this ui.debug happens before --debug is processed, | |
109 | # Use --config ui.debug=1 to see them. |
|
117 | # Use --config ui.debug=1 to see them. | |
110 | ui.debug('could not import %s (%s): trying %s\n' |
|
118 | ui.debug('could not import %s (%s): trying %s\n' | |
111 | % (failed, err, next)) |
|
119 | % (failed, _forbytes(err), next)) | |
112 | if ui.debugflag: |
|
120 | if ui.debugflag: | |
113 | ui.traceback() |
|
121 | ui.traceback() | |
114 |
|
122 | |||
@@ -168,6 +176,7 b' def loadall(ui):' | |||||
168 | except KeyboardInterrupt: |
|
176 | except KeyboardInterrupt: | |
169 | raise |
|
177 | raise | |
170 | except Exception as inst: |
|
178 | except Exception as inst: | |
|
179 | inst = _forbytes(inst) | |||
171 | if path: |
|
180 | if path: | |
172 | ui.warn(_("*** failed to import extension %s from %s: %s\n") |
|
181 | ui.warn(_("*** failed to import extension %s from %s: %s\n") | |
173 | % (name, path, inst)) |
|
182 | % (name, path, inst)) |
General Comments 0
You need to be logged in to leave comments.
Login now