Sublime Forum

Sublime Clang ST3 Error


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\”, line 504, in recompile
File “C:\Users\Nikhil\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\”, 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\”, 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\”, line 162, in expand_path
value = re.sub(r’${project_path}’, project_path, value)
File “X/”, line 170, in sub
File “X/”, line 288, in _subx
File “X/”, line 258, in wrapper
File “X/”, line 279, in _compile_repl
File “X/”, line 778, in parse_template
sre_constants.error: bad group name


Install Sublimeclang on ST3 (windows)

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.



What do you suggest is the solution ???



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


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)



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\", line 287, in on_selection_modified callback.on_selection_modified(v) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\", line 223, in on_selection_modified clang_error_panel.highlight_panel_row() File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\", line 116, in highlight_panel_row row, col = view.rowcol(view.sel()[0].a) AttributeError: 'NoneType' object has no attribute 'rowcol'



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\", line 488, in reparse_done display_compilation_results(self.view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\", line 247, in display_compilation_results tu = get_translation_unit(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\", line 78, in get_translation_unit stat = warm_up_cache(view, filename) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\", line 70, in warm_up_cache translationunitcache.tuCache.add(view, filename) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\", line 1179, in add opts = self.get_opts(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\", line 1219, in get_opts language = get_language(view) File "C:\Users\Kim\AppData\Roaming\Sublime Text 3\Packages\SublimeClang\internals\", line 93, in get_language caret = view.sel()[0].a File "C:\Program Files\Sublime Text 3\", line 450, in __getitem__ raise IndexError() IndexError



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: