summaryrefslogtreecommitdiffstats
path: root/Tools/pynche/PyncheWidget.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-07-06 22:00:52 (GMT)
committerBarry Warsaw <barry@python.org>1999-07-06 22:00:52 (GMT)
commit17a8b5d473f8adc6f16046754402bcf6ce4bce20 (patch)
tree2abd37cb46f9933c7a0baffb69e6624d8aa93941 /Tools/pynche/PyncheWidget.py
parent6166b871a24a7f983e0c48aaac264fef7c420738 (diff)
downloadcpython-17a8b5d473f8adc6f16046754402bcf6ce4bce20.zip
cpython-17a8b5d473f8adc6f16046754402bcf6ce4bce20.tar.gz
cpython-17a8b5d473f8adc6f16046754402bcf6ce4bce20.tar.bz2
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.
Diffstat (limited to 'Tools/pynche/PyncheWidget.py')
-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 d8ff8fa..4cddff1 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)