summaryrefslogtreecommitdiff
path: root/git/compat.py
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-09-29 01:07:41 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-09-29 01:46:15 +0200
commit395955609dfd711cc4558e2b618450f3514b28c1 (patch)
tree9ee15a36cbc05f9b509aedbda2373cfc0ace2d17 /git/compat.py
parentf1d2d0683afa6328b6015c6a3aa6a6912a055756 (diff)
downloadgitpython-395955609dfd711cc4558e2b618450f3514b28c1.tar.gz
FIX hook TC on PY3+Win & indeterministic lock timing.
+ Cannot `index.path` into ENV, it is bytes! + The hook TC never runs on linux! + Unblock removal of odbfile in perf-large streams TC. + Attempt to unblock removal of submodule file by intensive cleaning. more unblock files
Diffstat (limited to 'git/compat.py')
-rw-r--r--git/compat.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/git/compat.py b/git/compat.py
index d6be6ede..e760575d 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -66,6 +66,16 @@ def safe_decode(s):
raise TypeError('Expected bytes or text, but got %r' % (s,))
+def safe_encode(s):
+ """Safely decodes a binary string to unicode"""
+ if isinstance(s, unicode):
+ return s.encode(defenc)
+ elif isinstance(s, bytes):
+ return s
+ elif s is not None:
+ raise TypeError('Expected bytes or text, but got %r' % (s,))
+
+
def with_metaclass(meta, *bases):
"""copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""
class metaclass(meta):