griebd / clangHelper

Code completion for c/c++/objc/objc++ in Sublime Text 3 (using libclang)
MIT License
5 stars 0 forks source link

invalid start byte #3

Open daniele-niero opened 8 years ago

daniele-niero commented 8 years ago

Hello,

This error seems somehow similar to the others, but still slightly different to deserve an issues report all for it :)

Traceback (most recent call last):
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text 3\Packages\clangHelper\codeCompletion.py", line 15, in <module>
    from clang.cindex import TranslationUnit
ImportError: No module named 'clang'

During handling of the above exception, another exception occurred:

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 "./importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text 3\Packages\clangHelper\codeCompletion.py", line 19, in <module>
    if get_libclang_version() == '32':
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text 3\Packages\clangHelper\tools\libclang_version.py", line 24, in get_libclang_version
    print("VERISON DECODE", version().decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte

What generates the problem is this call version().decode() in libclang_version.py


System Information

Sublime:
    version: 3102
    platform: windows
    arch: x64
python:
    version: 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)]
    platform: Windows-7-6.1.7601-SP1
    arch: 64

I'm also pretty sure I have LLVM 64 bits. At least the installer claimed to be 64...

daniele-niero commented 8 years ago

I have noticed something.

Consider this code:

from ctypes import *

lib_file = 'libclang.dll'
lib = CDLL(lib_file)
print lib.clang_getClangVersion()

The result is every and each time different!! No wonder it causes problems. :(

Update the code above is not complete actually. refer to this please:

from ctypes import *

lib_file = 'libclang.dll'
lib = CDLL(lib_file)
version = lib.clang_getClangVersion
version.restype = c_char_p
print version()

Wich works just fine with LLVM 32 and called by some python 32, but returns always a different result with LLVM 64 and called with python 3.3 64 (from within Sublime 64)

griebd commented 8 years ago

ok, I don't know your background, so sorry if I say something you already know... :wink: Sublime Text won't use your system installed python, it is packed with its own! to do any test you need to open Sublime's console and enter your python codes there...

about your error, I don't have a windows machine to test, but apparently the try/catch is not working on windows.... try commenting out the try/catch letting the catch block as the only one available and tell the result, please.

daniele-niero commented 8 years ago

I'm quite proficient with python and I know all the intricacies with the different pythons installed :) but don't worry, you right to ask.

I have tried both with python 2.7 32 bit installed on my machine and with python 3.3 64 bit included in Sublime. Obviously being careful to use the right LLVM, 32 or 64.

Python 2.7 32 and LLVM (and clang) 32 bit, give back the right result. Disaster strikes with the 64 bit versions.

Now there is another problem. On windows the only binary distribution I have found of LLVM is version 3.9 (http://llvm.org/builds/). I don't even want to try to compile it myself on windows :). You included cindex38.py maximum, and in fact, even if I force the use of it, the plugin fails:

Traceback (most recent call last):
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\codeCompletion.py", line 208, in done
    set_view(self.view, True)
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\codeCompletion.py", line 123, in set_view
    TranslationUnit.PARSE_CACHE_COMPLETION_RESULTS)
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 2338, in from_source
    index = Index.create()
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 2225, in create
    return Index(conf.lib.clang_createIndex(excludeDecls, 0))
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 144, in __get__
    value = self.wrapped(instance)
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 3585, in lib
    register_functions(lib, not Config.compatibility_check)
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 3532, in register_functions
    list(map(register, functionList))
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 3530, in register
    return register_function(lib, item, ignore_errors)
  File "C:\Users\daniele.niero.LOST_BOYS_GAMES\AppData\Roaming\Sublime Text
3\Packages\clangHelper\clang\cindex38.py", line 3511, in register_function
    raise LibclangError(msg)
clangHelper.clang.cindex38.LibclangError: function
'clang_CXXField_isMutable' not found. Please ensure that your python
bindings are compatible with your libclang.so version.
griebd commented 8 years ago

I haven't noticed the new version of LLVM... just wait a bit (if I have the time tomorrow) and I will add it! it's just a matter of changing the LLVM python bindings to python 3, it's written in python 2...