Rev 6574: When unable to load an extension, explicitly name the extension. in http://bazaar.launchpad.net/~jameinel/unable-to-load

John Arbash Meinel john at arbash-meinel.com
Sun May 19 12:04:21 UTC 2013


At http://bazaar.launchpad.net/~jameinel/unable-to-load

------------------------------------------------------------
revno: 6574
revision-id: john at arbash-meinel.com-20130519120415-ozio9dyx337dglp8
parent: pqm at pqm.ubuntu.com-20130207092516-eax0tqbckd3oiaw8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: unable-to-load
timestamp: Sun 2013-05-19 13:04:15 +0100
message:
  When unable to load an extension, explicitly name the extension.
  
  On Windows, you aren't always guaranteed that the extension you are loading will
  be in the exception that is raised. It may be slightly redundant elsewhere, but
  it is quite helpful on Windows.
-------------- next part --------------
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py	2012-06-26 12:14:56 +0000
+++ b/bzrlib/annotate.py	2013-05-19 12:04:15 +0000
@@ -441,5 +441,5 @@
 try:
     from bzrlib._annotator_pyx import Annotator
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_annotator_pyx")
     from bzrlib._annotator_py import Annotator

=== modified file 'bzrlib/bencode.py'
--- a/bzrlib/bencode.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/bencode.py	2013-05-19 12:04:15 +0000
@@ -23,5 +23,5 @@
 try:
     from bzrlib._bencode_pyx import bdecode, bdecode_as_tuple, bencode, Bencached
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_bencode_pyx")
     from bzrlib.util._bencode_py import bdecode, bdecode_as_tuple, bencode, Bencached

=== modified file 'bzrlib/btree_index.py'
--- a/bzrlib/btree_index.py	2012-09-05 18:16:08 +0000
+++ b/bzrlib/btree_index.py	2013-05-19 12:04:15 +0000
@@ -1604,5 +1604,5 @@
     from bzrlib import _btree_serializer_pyx as _btree_serializer
     _gcchk_factory = _btree_serializer._parse_into_chk
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_btree_serializer_pyx")
     from bzrlib import _btree_serializer_py as _btree_serializer

=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/chk_map.py	2013-05-19 12:04:15 +0000
@@ -1733,7 +1733,7 @@
         _deserialise_internal_node,
         )
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_chk_map_pyx")
     from bzrlib._chk_map_py import (
         _bytes_to_text_key,
         _search_key_16,

=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2012-01-24 01:35:56 +0000
+++ b/bzrlib/dirstate.py	2013-05-19 12:04:15 +0000
@@ -4258,7 +4258,7 @@
         update_entry as update_entry,
         )
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_dirstate_helpers_pyx")
     from bzrlib._dirstate_helpers_py import (
         _read_dirblocks,
         bisect_dirblock,

=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2011-12-18 15:28:38 +0000
+++ b/bzrlib/graph.py	2013-05-19 12:04:15 +0000
@@ -1711,5 +1711,5 @@
 try:
     from bzrlib._known_graph_pyx import KnownGraph
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_known_graph_pyx")
     from bzrlib._known_graph_py import KnownGraph

=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/groupcompress.py	2013-05-19 12:04:15 +0000
@@ -2206,6 +2206,6 @@
         )
     GroupCompressor = PyrexGroupCompressor
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_groupcompress_pyx")
     GroupCompressor = PythonGroupCompressor
 

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/knit.py	2013-05-19 12:04:15 +0000
@@ -3501,5 +3501,5 @@
 try:
     from bzrlib._knit_load_data_pyx import _load_data_c as _load_data
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_knit_load_data_pyx")
     from bzrlib._knit_load_data_py import _load_data_py as _load_data

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2012-09-19 07:58:27 +0000
+++ b/bzrlib/osutils.py	2013-05-19 12:04:15 +0000
@@ -1058,7 +1058,7 @@
 _extension_load_failures = []
 
 
-def failed_to_load_extension(exception):
+def failed_to_load_extension(exception, extension_name=None):
     """Handle failing to load a binary extension.
 
     This should be called from the ImportError block guarding the attempt to
@@ -1068,7 +1068,8 @@
     >>> try:
     >>>     import bzrlib._fictional_extension_pyx
     >>> except ImportError, e:
-    >>>     bzrlib.osutils.failed_to_load_extension(e)
+    >>>     bzrlib.osutils.failed_to_load_extension(e,
+    >>>         '_fictional_extension_pyx')
     >>>     import bzrlib._fictional_extension_py
     """
     # NB: This docstring is just an example, not a doctest, because doctest
@@ -1081,7 +1082,12 @@
     # with 10 warnings.
     exception_str = str(exception)
     if exception_str not in _extension_load_failures:
-        trace.mutter("failed to load compiled extension: %s" % exception_str)
+        if not extension_name:
+            extension_bit = ''
+        else:
+            extension_bit = '%s ' % (extension_name,)
+        trace.mutter("failed to load compiled extension: %s%s" %
+                (extension_bit, exception_str))
         _extension_load_failures.append(exception_str)
 
 

=== modified file 'bzrlib/rio.py'
--- a/bzrlib/rio.py	2011-12-18 15:28:38 +0000
+++ b/bzrlib/rio.py	2013-05-19 12:04:15 +0000
@@ -381,7 +381,7 @@
         _valid_tag,
         )
 except ImportError, e:
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_rio_pyx")
     from bzrlib._rio_py import (
        _read_stanza_utf8,
        _read_stanza_unicode,

=== modified file 'bzrlib/static_tuple.py'
--- a/bzrlib/static_tuple.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/static_tuple.py	2013-05-19 12:04:15 +0000
@@ -24,7 +24,7 @@
     from bzrlib._static_tuple_c import StaticTuple
 except ImportError, e:
     from bzrlib import osutils
-    osutils.failed_to_load_extension(e)
+    osutils.failed_to_load_extension(e, "_static_tuple_c")
     from bzrlib._static_tuple_py import StaticTuple
 
 



More information about the bazaar-commits mailing list