Skip to content

Fixed encoding issue. See #35 #81

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion git_cc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def decodeString(encoding, encodestr):
return encodestr.decode(encoding)
except UnicodeDecodeError as e:
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...


def tag(tag, id="HEAD"):
git_exec(['tag', '-f', tag, id])
Expand Down