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

amalgamate.py fails with a encoding/decoding error #65

Closed
lu-zero opened this issue Dec 8, 2019 · 3 comments
Closed

amalgamate.py fails with a encoding/decoding error #65

lu-zero opened this issue Dec 8, 2019 · 3 comments

Comments

@lu-zero
Copy link

lu-zero commented Dec 8, 2019

Generate source file /usr/src/hawktracer/.build/hawktracer.cpp
Traceback (most recent call last):
  File "/usr/src/hawktracer/tools/amalgamate.py", line 308, in <module>
    run_program(sys.argv[1:])
  File "/usr/src/hawktracer/tools/amalgamate.py", line 304, in run_program
    Amalgamator(args.root_dir, header_file, source_file).generate()
  File "/usr/src/hawktracer/tools/amalgamate.py", line 284, in generate
    self._generate_source_file()
  File "/usr/src/hawktracer/tools/amalgamate.py", line 276, in _generate_source_file
    source_file_dumper.dump_file(os.path.join(self._lib_dir, source_file))
  File "/usr/src/hawktracer/tools/amalgamate.py", line 216, in dump_file
    for line in f:
  File "/usr/lib64/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3101: ordinal not in range(128)
python --version
Python 3.5.9

On bb3a3ac

@loganek
Copy link
Member

loganek commented Dec 8, 2019

Thanks @lu-zero for the report. I've checked on my environment and couldn't reproduce the issue. Could you please provide more details about the operating system you're running the command on?
Also, could you try the following command in your .build directory and see if the result is the same?

python3 ../tools/amalgamate.py --root-dir .. --out-dir . --config-path lib/include/hawktracer/ht_config.h  --cpp

Thank you

@lu-zero
Copy link
Author

lu-zero commented Dec 8, 2019

I doublechecked and the problem is that apparently if your locale is POSIX and not POSIX.utf-8 the read-file-by-line iterator crashes horribly.

The workaround is to set a POSIX.utf-8 locale.

loganek added a commit that referenced this issue Dec 17, 2019
This caused problems when running amalgamation script with non-UTF-8 locale

Solves: #65
@loganek
Copy link
Member

loganek commented Dec 17, 2019

The real problem was that in the source code we had non-ascii characters (0xe2) which shouldn't be there. I removed them and the script works fine even with POSIX locale.
@lu-zero again thanks a lot for the report, and sorry for inconvenience

@loganek loganek closed this as completed Dec 17, 2019
loganek added a commit to loganek/hawktracer that referenced this issue Jan 12, 2020
This caused problems when running amalgamation script with non-UTF-8 locale

Solves: amzn#65
loganek added a commit that referenced this issue Jan 19, 2020
This caused problems when running amalgamation script with non-UTF-8 locale

Solves: #65
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

2 participants