Permalink
Browse files

Handled case where there is no active view and we can't get the user'…

…s settings (fall back to using 'python' executable, rather than looking in settings for the 'python_executable' setting.
  • Loading branch information...
1 parent c4e357a commit ff4094197baeca35da3dc93dd98cb79f95947af0 @glenrobertson glenrobertson committed Apr 27, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 python_open_module.py
View
@@ -24,11 +24,18 @@ def find_module(self, module, path):
"""
def get_user_syspath(self):
- try:
+ active_view = self.window.active_view()
+
+ # can only obtain user settings from a view for some reason
+ if active_view:
# if the user has a python_executable in their project settings, use that
# otherwise use `python`
- python_executable = self.window.active_view().settings().get('python_executable', 'python')
+ python_executable = active_view.settings().get('python_executable', 'python')
+ # can't determine user settings, so use `python`
+ else:
+ python_executable = 'python'
+ try:
# try to get sys.path from the python executable
args = [python_executable, '-c', 'import sys; print sys.path']
sys_path = eval(subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0])

0 comments on commit ff40941

Please sign in to comment.