summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2017-03-07 20:56:32 -0500
committerSebastian Thiel <byronimo@gmail.com>2017-03-08 06:01:03 +0100
commit9ce2a4b235d2ebc38c3e081c1036e39bde9be036 (patch)
tree0a577c3c11f85845721027824afea8f8e668a5f5
parent96402136e81bd18ed59be14773b08ed96c30c0f6 (diff)
downloadgitpython-9ce2a4b235d2ebc38c3e081c1036e39bde9be036.tar.gz
BF: pass original exception into replace_surrogate_encode
Fixes my incorrect fix in #598
-rw-r--r--git/compat.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/git/compat.py b/git/compat.py
index 484f2391..b8045857 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -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:
@@ -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.
@@ -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)]