Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues when run with python 3.4.3 on Windows #3

Open
satya-das opened this issue Sep 20, 2017 · 2 comments
Open

Issues when run with python 3.4.3 on Windows #3

satya-das opened this issue Sep 20, 2017 · 2 comments

Comments

@satya-das
Copy link

I used this tool to generate mock class of wxDC which is part of wxWidgets and I got some error. I used below command:
gmock.py dc.h -- -DWXDLLIMPEXP_CORE= -DWXWIN_COMPATIBILITY_2_8=0 -DWXDLLIMPEXP_FWD_CORE=
I got some error regarding encode and decode of strings, e.g.:
str(node.spelling, self.encode)
After fixing them I got below error:

File "C:\Tools\gmock.py\clang\cindex.py", line 95, in value
return super(c_char_p, self).value.decode("utf8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 0: invalid continuation byte

It will be great if you can take a look. I attached the file with which I ran this.
dc.txt
Github doesn't support .h file and so I have renamed it to .txt.

@theidexisted
Copy link

theidexisted commented Aug 19, 2020

The code seems haven't been properly tested with Python 3, I have changed str(node.spelling, self.encode) into node.spelling and then replace the clang python binding with clang 10 python binding and finally run successfully with these suites (On Ubuntu 20.04):

  • python 3.8.2
  • llvm/clang 10
  • clang python binding 10

@LiuWenJia-ops
Copy link

hi satya-das, Ive met the same problem! I solve it by changing
return super(c_char_p, self).value.decode("utf8")
to
return super(c_char_p, self).value.decode("utf8", error = 'ignore')

cuz if you dont explicitly set error, by default it's like bytes.decode(encoding="utf-8", errors="strict")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants