Skip to content

Fixed crash on non-ascii diff #644

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

Merged
merged 1 commit into from
Mar 15, 2017

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Mar 15, 2017

Sometimes the diff file would contain a unicode character. Since we were opening the file, this meant that unidiff was reading the file in the wrong format. By letting unidiff handle reading the file we slightly simplify the code and fix this problem.

Sometimes the diff file would contain a unicode character. Since we were
opening the file, this meant that unidiff was reading the file in the
wrong format. By letting unidiff handle reading the file we slightly
simplify the code and fix this problem.
@thk123
Copy link
Contributor Author

thk123 commented Mar 15, 2017

Error that prompted this:

The linter output is below (empty output means no errors).
Traceback (most recent call last):
  File "scripts/filter_lint_by_diff.py", line 15, in <module>
    diff = unidiff.PatchSet(f)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 278, in __init__
    self._parse(data, encoding=encoding)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 320, in _parse
    current_file._parse_hunk(line, diff, encoding)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 216, in _parse_hunk
    hunk.append(original_line)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 132, in append
    s = str(line)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 53, in <lambda>
    cls.__str__ = lambda x: x.__unicode__().encode(DEFAULT_ENCODING)
  File "/usr/local/lib/python2.7/site-packages/unidiff/patch.py", line 79, in __str__
    return "%s%s" % (self.line_type, self.value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 79: ordinal not in range(128)

@kroening kroening merged commit fee04d6 into diffblue:master Mar 15, 2017
@thk123 thk123 deleted the bugfix/lint-non-ascii-crash branch March 16, 2017 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants