Sublime Forum

Sublime Clang ST3 Error

#1

I am getting an error in ST3 for sublimeclang whenever the folder name starts with the letter g… the console shows the following

Writing file /D/g12/a.c with encoding UTF-8 (atomic)
Traceback (most recent call last):
File “C:\Users\Nikhil\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\sublimeclang.py”, line 504, in recompile
self.reparse_done):
File “C:\Users\Nikhil\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\translationunitcache.py”, line 1154, in reparse
(filename, self.get_opts(view), self.get_opts_script(view), unsaved_files, on_done)))
File “C:\Users\Nikhil\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\translationunitcache.py”, line 1191, in get_opts_script
return expand_path(get_setting(“options_script”, “”, view), view.window())
File “C:\Users\Nikhil\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\common.py”, line 162, in expand_path
value = re.sub(r’${project_path}’, project_path, value)
File “X/re.py”, line 170, in sub
File “X/re.py”, line 288, in _subx
File “X/functools.py”, line 258, in wrapper
File “X/re.py”, line 279, in _compile_repl
File “X/sre_parse.py”, line 778, in parse_template
sre_constants.error: bad group name

0 Likes

Install Sublimeclang on ST3 (windows)
#2

Hmm… my first guess is that the project_path is not properly escaped when used in re.sub(). Directories starting with \g (in Windows) include an unwanted \g regex notation.

0 Likes

#3

What do you suggest is the solution ???

0 Likes

#4

I was able to reproduce this and fix it… just replaced the lines 161-2 in internals/common.py with this:

[code]

project_path = project_path.replace("\", “\\”) # Path will be used within a regex, thus escape every backslash
if project_path:
value = re.sub(r’${project_path}’, project_path, value)[/code]

EDIT: Escaper should have been put in to the if clause :unamused:

if project_path: project_path = project_path.replace("\\", "\\\\") # Path will be used within a regex, thus escape every backslash value = re.sub(r'\${project_path}', project_path, value)

0 Likes

#5

Have you got the following error? Don’t know what trigged this, but it seems to be harmless (doesn’t cause any visible errors for the end user).

Writing file /C/Users/Kim/Documents/Workspace/gtest/main.cpp with encoding UTF-8 (atomic) Traceback (most recent call last): File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 287, in on_selection_modified callback.on_selection_modified(v) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\errormarkers.py", line 223, in on_selection_modified clang_error_panel.highlight_panel_row() File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\errormarkers.py", line 116, in highlight_panel_row row, col = view.rowcol(view.sel()[0].a) AttributeError: 'NoneType' object has no attribute 'rowcol'

0 Likes

#6

Just got this IndexError as well (again seems to be invisible for the end user):

Traceback (most recent call last): File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\sublimeclang.py", line 488, in reparse_done display_compilation_results(self.view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\sublimeclang.py", line 247, in display_compilation_results tu = get_translation_unit(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\sublimeclang.py", line 78, in get_translation_unit stat = warm_up_cache(view, filename) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\sublimeclang.py", line 70, in warm_up_cache translationunitcache.tuCache.add(view, filename) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\translationunitcache.py", line 1179, in add opts = self.get_opts(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\translationunitcache.py", line 1219, in get_opts language = get_language(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\common.py", line 93, in get_language caret = view.sel()[0].a File "C:\Program Files\Sublime Text 3\sublime.py", line 450, in __getitem__ raise IndexError() IndexError

0 Likes

#7

I havent got the error you mentioned… but will see if it appears… regarding the issue with folders starting with g your fix solved the issue… great work… thanks a lot… Hope this helps other c developers looking for sublimeclang in ST3 :smiley:

0 Likes