Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sanitizes log message input Fixes issue #478 in which invalid utf-8 characters that appeared in test output were causing unhandled exceptions to be raised. The fix uses built-in sanitization features to replace invalid characters with '?'. * Fixes Python2/3 queue import error in test code * Fixes unknown 'to_bytes' unittest for Python2
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
try: | ||
# Python3 | ||
from queue import Queue | ||
except ImportError: | ||
# Python2 | ||
from Queue import Queue | ||
|
||
import binascii | ||
from catkin_tools.execution import io as io | ||
|
||
|
||
def test_invalid_utf8_characters(): | ||
io_container = io.IOBufferContainer('test', 'test_id', 'test', Queue(), '/tmp') | ||
bad_byte_array = binascii.a2b_hex(b'80') | ||
try: | ||
io_container._decode(bad_byte_array) | ||
except UnicodeDecodeError: | ||
assert False, "Bad decoding" |