mapbox / mapbox/cncc

AttributeError: 'CompileCommand' object has no attribute 'encode'

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
127
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Hi I found this project while looking for a regex-based check to clang-tidy for checking a highly non-standard naming convention and I thought I'd give it a go.

I installed:
python 3.8 (win python distribution - i'm running windows)
clang 11.0 (https://pypi.org/project/clang/)
pyyaml 5.3.1 (https://pypi.org/project/PyYAML/)

I have clang 10.0.0 installed aswell and added the libclang.dll to my PATH. Prior to running cncc I also generated a compiler database.

When I run python.exe cncc --style examples\basic.style --dbdir d:\path\to\folder\with\compile\database d:\some\file.c d:\some\other\file.c I get the following error:

Traceback (most recent call last):
File "cncc", line 44, in
unit = index.parse(f, args=commands)
File "C:\Users\username\Desktop\WPy64-3850\python-3.8.5.amd64\lib\site-packages\clang\cindex.py", line 2721, in parse
return TranslationUnit.from_source(path, args, unsaved_files, options,
File "C:\Users\username\Desktop\WPy64-3850\python-3.8.5.amd64\lib\site-packages\clang\cindex.py", line 2816, in from_source
args_array = (c_char_p * len(args))([b(x) for x in args])
File "C:\Users\username\Desktop\WPy64-3850\python-3.8.5.amd64\lib\site-packages\clang\cindex.py", line 2816, in
args_array = (c_char_p * len(args))(
[b(x) for x in args])
File "C:\Users\username\Desktop\WPy64-3850\python-3.8.5.amd64\lib\site-packages\clang\cindex.py", line 109, in b
return x.encode('utf8')
AttributeError: 'CompileCommand' object has no attribute 'encode'

I was hoping maybe you could shed a little light on this? The compilation database works fine when using just clang-tidy, so I don't suppose it's corrupt in any way.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at cncc line 44, where each file is passed to index.parse, and inspect how the compilation database entries are used as its args. Reproduce the Windows command with the reported Python, clang, and PyYAML versions, then verify that the listed C files can be parsed without the CompileCommand AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.