diff --git a/mercurial/extensions.py b/mercurial/extensions.py
index 3a75fcc96dac682dae610644bae12faf0cfa9aa2_bWVyY3VyaWFsL2V4dGVuc2lvbnMucHk=..f8a86ea7521bc5e88bb0e32311f6fd63537cd662_bWVyY3VyaWFsL2V4dGVuc2lvbnMucHk= 100644
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -78,8 +78,12 @@
         except (util.SignalInterrupt, KeyboardInterrupt):
             raise
         except Exception, inst:
-            ui.warn(_("*** failed to import extension %s: %s\n") %
-                    (name, inst))
+            if path:
+                ui.warn(_("*** failed to import extension %s from %s: %s\n")
+                        % (name, path, inst))
+            else:
+                ui.warn(_("*** failed to import extension %s: %s\n")
+                        % (name, inst))
             if ui.print_exc():
                 return 1
 
diff --git a/tests/test-bad-extension b/tests/test-bad-extension
index 3a75fcc96dac682dae610644bae12faf0cfa9aa2_dGVzdHMvdGVzdC1iYWQtZXh0ZW5zaW9u..f8a86ea7521bc5e88bb0e32311f6fd63537cd662_dGVzdHMvdGVzdC1iYWQtZXh0ZW5zaW9u 100755
--- a/tests/test-bad-extension
+++ b/tests/test-bad-extension
@@ -7,4 +7,5 @@
 echo "gpg =" >> $HGRCPATH
 echo "hgext.gpg =" >> $HGRCPATH
 echo "badext = $abspath" >> $HGRCPATH
+echo "badext2 =" >> $HGRCPATH
 
@@ -10,2 +11,3 @@
 
-hg -q help help
+hg -q help help 2>&1 | python -c \
+  "import sys; sys.stdout.write(sys.stdin.read().replace('$abspath', '.../badext.py'))"
diff --git a/tests/test-bad-extension.out b/tests/test-bad-extension.out
index 3a75fcc96dac682dae610644bae12faf0cfa9aa2_dGVzdHMvdGVzdC1iYWQtZXh0ZW5zaW9uLm91dA==..f8a86ea7521bc5e88bb0e32311f6fd63537cd662_dGVzdHMvdGVzdC1iYWQtZXh0ZW5zaW9uLm91dA== 100644
--- a/tests/test-bad-extension.out
+++ b/tests/test-bad-extension.out
@@ -1,4 +1,5 @@
-*** failed to import extension badext: bit bucket overflow
+*** failed to import extension badext from .../badext.py: bit bucket overflow
+*** failed to import extension badext2: No module named badext2
 hg help [COMMAND]
 
 show help for a command, extension, or list of commands