diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-01 16:02:20 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-01 16:33:20 +0200 |
commit | b8b025f719b2c3203e194580bbd0785a26c08ebd (patch) | |
tree | 8cec9ba13035f9489fdaa56e550e93bc976372fc /git/compat.py | |
parent | a79cf677744e2c1721fa55f934fa07034bc54b0a (diff) | |
download | gitpython-b8b025f719b2c3203e194580bbd0785a26c08ebd.tar.gz |
Win, #519: FIX repo TCs.
+ FIX TestRepo.test_submodule_update():
+ submod: del `.git` file prior overwrite; Windows denied otherwise!
+ FIX TestRepo.test_untracked_files():
+ In the `git add <file>` case, it failed with unicode args on PY2.
Had to
encode them with `locale.getpreferredencoding()` AND use SHELL.
+ cmd: add `shell` into `execute()` kwds, for overriding USE_SHELL per
command.
+ repo: replace blocky `communicate()` in `_clone()` with thread-pumps.
+ test_repo.py: unittestize (almost all) assertions.
+ Replace open --> with open for index (base and TC).
+ test_index.py: Enabled a dormant assertion.
Diffstat (limited to 'git/compat.py')
-rw-r--r-- | git/compat.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/git/compat.py b/git/compat.py index e760575d..441a3761 100644 --- a/git/compat.py +++ b/git/compat.py @@ -7,6 +7,7 @@ """utilities to help provide compatibility with python 3""" # flake8: noqa +import locale import os import sys @@ -15,7 +16,6 @@ from gitdb.utils.compat import ( MAXSIZE, izip, ) - from gitdb.utils.encoding import ( string_types, text_type, @@ -23,6 +23,7 @@ from gitdb.utils.encoding import ( force_text ) + PY3 = sys.version_info[0] >= 3 is_win = (os.name == 'nt') is_posix = (os.name == 'posix') @@ -76,6 +77,16 @@ def safe_encode(s): raise TypeError('Expected bytes or text, but got %r' % (s,)) +def win_encode(s): + """Encode unicodes for process arguments on Windows.""" + if isinstance(s, unicode): + return s.encode(locale.getpreferredencoding(False)) + 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): |