Skip to content

Commit

Permalink
Resolve import errors in Python3
Browse files Browse the repository at this point in the history
The built-in interpreter in Sublime Text 3 raises 'ImportError'
exceptions if imports aren't relative to the 'Packages' directory.
The same issue doesn't occur in the standard Python3 interpreter.
Resolve the issue by hacking the path when running in Sublime Text.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
  • Loading branch information
stephenfin committed Oct 19, 2014
1 parent cf8f0d7 commit 48f1cd3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions ctagsplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@
import sublime
import sublime_plugin
from sublime import status_message, error_message

# hack the system path to prevent the following issue in ST3
# ImportError: No module named 'ctags'
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
except ImportError: # running tests
from tests.sublime_fake import sublime
from tests.sublime_fake import sublime_plugin

sys.modules['sublime'] = sublime
sys.modules['sublime_plugin'] = sublime_plugin

if sys.version_info < (3, 0):
import ctags
from ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
TagElements, TagFile)
from helpers.edit import Edit
else:
from CTags import ctags
from CTags.ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
TagElements, TagFile)
from CTags.helpers.edit import Edit
import ctags
from ctags import (FILENAME, parse_tag_lines, PATH_ORDER, SYMBOL,
TagElements, TagFile)
from helpers.edit import Edit

#
# Contants
Expand Down

0 comments on commit 48f1cd3

Please sign in to comment.