summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-07-06 22:00:52 +0000
committerBarry Warsaw <barry@python.org>1999-07-06 22:00:52 +0000
commit023c1ee756b433a25f973097ec5a1c9fc74a2fb9 (patch)
tree3c0690a3ddff18a2bd6fc9eebf1f9dda2e5d9984
parent9c05b63c65433d42bcd0e8ab5dcc674218468962 (diff)
downloadcpython-023c1ee756b433a25f973097ec5a1c9fc74a2fb9.tar.gz
make_view_popups(): Catch import error which can occur if a viewer is
dynamically imported when Pynche is running via askcolor out of a package. If the ImportError occurs, try again, prepending the package name and digging out the module.
-rw-r--r--Tools/pynche/PyncheWidget.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Tools/pynche/PyncheWidget.py b/Tools/pynche/PyncheWidget.py
index d8ff8facdb..4cddff1771 100644
--- a/Tools/pynche/PyncheWidget.py
+++ b/Tools/pynche/PyncheWidget.py
@@ -294,7 +294,13 @@ def make_view_popups(switchboard, root, extrapath):
for file in os.listdir(dir):
if file[-9:] == 'Viewer.py':
name = file[:-3]
- module = __import__(name)
+ try:
+ module = __import__(name)
+ except ImportError:
+ # Pynche is running from inside a package, so get the
+ # module using the explicit path.
+ pkg = __import__('pynche.'+name)
+ module = getattr(pkg, name)
if hasattr(module, 'ADDTOVIEW') and module.ADDTOVIEW:
# this is an external viewer
v = PopupViewer(module, name, switchboard, root)