Details: a small verifiable The example is in the Github repo
Essentially, there is a script that uses a slightly changed cindex.py (compatible with python 3 and clang 3.8) and builds the translation unit from the test source file. Then it re-parses it And tried to finish.
The script works as expected when using Powershell’s Python 3.3.5.
When put into the Packages folder on Sublime Text 3, it produces an error. The Python version reported by Sublime Text 3 is 3.3.6. Error:
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 78, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/__init__.py", line 90, in import_module
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "< frozen importlib._bootstrap>", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module< br /> File " ", line 313, in _call_with_frames_removed
File "C:\Users\igor\AppData\Roaming\Sublime Text 3\Packages\test_clang\script.py", line 21 , in
tu = TU.from_source(filename=filename)
File "C:\Users\igor\AppData\Roaming\Sublime Text 3\Packages\test_clang\clang\cindex38.py" , line 2372, in from_source
raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex38.TranslationUnitLoadError: Error parsing translation unit.
This happens because of cindex The ptr to tranlation unit returned by libclang in .py is None. The only strange thing to me is that it only happens in python bundled with sublime text 3.
It also happens to others NS? Does anyone know what could be the reason or how to debug it?
If you can’t run the examples provided here, feel free to ping me.
UPD: In the question of the test project, we found that it is not the ctypes bundled in the sublime text . Replacing the text in the sublime text with the text installed in the system will produce the same error.
UPD2: I have deleted the cindex.py file in the test repository, which only contains the problems encountered State the minimum code required for the same problem. Maybe this helps to generate new ideas about what might go wrong? Also, I want to make it clear that the same code works exactly as expected on Linux and OSX.
This means, As long as a version of sublime text comes with an updated python, we will not see this problem.
Short note: using libclang to autocomplete code is not applicable to Sublime Text 3 is bundled with python.
Details: A small verifiable example is in the Github repo
In essence, there is a script that uses slightly changed cindex.py (compatible with python 3 and clang 3.8) and builds the translation unit from the test source file. Then it reparses it and tries to finish.
The script works as expected when using Powershell’s Python 3.3.5 Works.
When put into the Packages folder on Sublime Text 3, an error will occur. The Python version reported by Sublime Text 3 is 3.3.6. Error:
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 78, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/__init__.py", line 90, in import_module
File "", line 1584, in _gcd_import
File "< frozen importlib._bootstrap>", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module
File "", line 313, in _call_with_frames_removed
File "C:\Users\igor\AppData\Roaming\Sublime Text 3\Packages\test_clang \script.py", line 21, in
tu = TU.from_source(filename=filename)
File "C:\Users\igor\AppData\Roaming\Sublime Text 3\Packages\ test_clang\clang\cindex38.py", line 2372, in from_source
raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex38.TranslationUnitLoadError: Error parsing translation unit.
Will it happen to others too? Does anyone know what could be the reason or how to debug it?
If you can’t run the examples provided here, feel free to ping me.
UPD: In the question of the test project, we found that it is not the ctypes bundled in the sublime text . Replacing the text in the sublime text with the text installed in the system will produce the same error.
UPD2: I have deleted the cindex.py file in the test repository, which only contains the problems encountered State the minimum code required for the same problem. Maybe this helps to generate new ideas about what might go wrong? Also, I want to make it clear that the same code works exactly as expected on Linux and OSX.
Unfortunately, now the answer to this question is that it It is due to a bug in Python 3.3 that is bundled with Sublime Text 3. Please refer to the discussion on the Sublime Text forum.
This means that as long as a version of sublime text comes with an updated python , We won’t see this problem.