Skip to content

Conversation

@faisal-hameed
Copy link

Fixed encoding issue due to non-utf8 characters in commit messages.

print >> sys.stderr, encodestr, ":", e
return encodestr.decode(encoding, "ignore")
ascii_only = re.sub(r'[^\x00-\x7f]',r' ',encodestr)
return encodestr.decode(ascii_only, "ignore")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious, isn't the whole point of "ignore" here to stop errors being thrown?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @charleso,
and the fact that the original code does not work seems to indicate that the exception thrown is not the one you are trying to catch here.
According to the docs the exception to catch is
UnicodeError
instead of
UnicodeDecodeError

bytes.decode(encoding='utf-8', errors='strict')
bytearray.decode(encoding='utf-8', errors='strict')
Return a string decoded from the given bytes. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a UnicodeError. Other possible values are 'ignore', 'replace' and any other name registered via codecs.register_error(), see section Error Handlers. For a list of possible encodings, see section Standard Encodings.

Just trying to see if that works...

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

Successfully merging this pull request may close these issues.

3 participants