Skip to content

Remove Python 2 compatibility shims #56

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 10 commits into from
Feb 17, 2020
Prev Previous commit
Next Next commit
Remove and replace encoding.text_type
  • Loading branch information
Harmon758 committed Feb 16, 2020
commit 77dc809542d15c40dbe60ff55cd830082c3ad904
15 changes: 2 additions & 13 deletions gitdb/utils/encoding.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
from gitdb.utils import compat

if compat.PY3:
text_type = str
else:
text_type = unicode


def force_bytes(data, encoding="ascii"):
if isinstance(data, bytes):
return data
Expand All @@ -17,13 +9,10 @@ def force_bytes(data, encoding="ascii"):


def force_text(data, encoding="utf-8"):
if isinstance(data, text_type):
if isinstance(data, str):
return data

if isinstance(data, bytes):
return data.decode(encoding)

if compat.PY3:
return text_type(data, encoding)
else:
return text_type(data)
return str(data, encoding)