[MERGE] Allow -Derror to show exceptions caused by plugin import errors.

John Arbash Meinel john at arbash-meinel.com
Thu May 15 17:56:22 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
| Hi,
|
| Here's my attempt to make -Derror show exceptions from plugin import
| problems. I'm not sure it's the right way to go about it though.
|
| For one thing, I don't know if sys.stderr.write will give encoding
| problems? Also, perhaps there's some other code I missed that will call
| this, and would lead to the double printing of exception that I tried
| to avoid.
|
| Any review would be appreciated.
|
| Thanks,
|
| James
|
|

I would expect that format_exc() actually generates an 8-bit string, not a
Unicode object, so sys.stderr.write() shouldn't error.

If I were doing it, I would probably have 'allow_debug=False' for api
compatibility, and then just in the plugin importer supply "allow_debug=True".

If you look at "report_error()" it is being passed 'sys.stderr' from
bzrlib.commands.run_bzr_catch_errors.

But also, looking at the code, it seems more appropriate would be something like:

=== modified file 'bzrlib/plugin.py'
- --- bzrlib/plugin.py    2008-04-06 08:36:27 +0000
+++ bzrlib/plugin.py    2008-05-15 16:54:49 +0000
@@ -299,6 +299,8 @@
~             warning('Unable to load plugin %r from %r'
~                     % (name, zip_name))
~             log_exception_quietly()
+            if 'error' in debug.debug_flags:
+                trace.report_bug(sys.exc_info, sys.stderr)


~ def plugins():

I'm not positive, though, because report_bug probably says to go report this to
launchpad.net, which probably isn't valid.

BB:resubmit

So I would rather keep api compatibility for 'log_exception_quietly' at the
least. And probably use one of the trace functions for reporting to the user,
but there are a couple of options there.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgsazYACgkQJdeBCYSNAAPTgACfUC7pp3/7+HXT/7vRn3/xl7DK
2MMAnRxU+Acc4lUPSmJ6VSJsvFQ7HGeD
=z8ia
-----END PGP SIGNATURE-----



More information about the bazaar mailing list