Skip to content

BF: pass original exception into replace_surrogate_encode #603

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 8, 2017
Merged
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
6 changes: 3 additions & 3 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def surrogateescape_handler(exc):
# exception anyway after this function is called, even though I think
# it's doing what it should. It seems that the strict encoder is called
# to encode the unicode string that this function returns ...
decoded = replace_surrogate_encode(mystring)
decoded = replace_surrogate_encode(mystring, exc)
else:
raise exc
except NotASurrogateError:
Expand All @@ -189,7 +189,7 @@ class NotASurrogateError(Exception):
pass


def replace_surrogate_encode(mystring):
def replace_surrogate_encode(mystring, exc):
"""
Returns a (unicode) string, not the more logical bytes, because the codecs
register_error functionality expects this.
Expand All @@ -204,7 +204,7 @@ def replace_surrogate_encode(mystring):
# The following magic comes from Py3.3's Python/codecs.c file:
if not 0xD800 <= code <= 0xDCFF:
# Not a surrogate. Fail with the original exception.
raise NotASurrogateError
raise exc
# mybytes = [0xe0 | (code >> 12),
# 0x80 | ((code >> 6) & 0x3f),
# 0x80 | (code & 0x3f)]
Expand Down