summaryrefslogtreecommitdiff
path: root/fastimport
diff options
context:
space:
mode:
Diffstat (limited to 'fastimport')
-rw-r--r--fastimport/commands.py12
-rw-r--r--fastimport/helpers.py17
-rw-r--r--fastimport/parser.py2
-rw-r--r--fastimport/py.typed0
4 files changed, 8 insertions, 23 deletions
diff --git a/fastimport/commands.py b/fastimport/commands.py
index 6278c78..9cd72ee 100644
--- a/fastimport/commands.py
+++ b/fastimport/commands.py
@@ -70,10 +70,7 @@ class ImportCommand(object):
return repr(self)
def __repr__(self):
- if sys.version_info[0] == 2:
- return self.__bytes__()
- else:
- return bytes(self).decode('utf8')
+ return bytes(self).decode('utf8')
def __bytes__(self):
raise NotImplementedError(
@@ -470,11 +467,8 @@ def check_path(path):
if path is None or path == b'' or path.startswith(b'/'):
raise ValueError("illegal path '%s'" % path)
- if (
- (sys.version_info[0] >= 3 and not isinstance(path, bytes)) and
- (sys.version_info[0] == 2 and not isinstance(path, str))
- ):
- raise TypeError("illegale type for path '%r'" % path)
+ if not isinstance(path, bytes):
+ raise TypeError("illegal type for path '%r'" % path)
return path
diff --git a/fastimport/helpers.py b/fastimport/helpers.py
index e252d09..78fe50c 100644
--- a/fastimport/helpers.py
+++ b/fastimport/helpers.py
@@ -104,24 +104,15 @@ def is_inside_any(dir_list, fname):
def utf8_bytes_string(s):
"""Convert a string to a bytes string (if necessary, encode in utf8)"""
- if sys.version_info[0] == 2:
- if isinstance(s, str):
- return s
- else:
- return s.encode('utf8')
+ if isinstance(s, str):
+ return bytes(s, encoding='utf8')
else:
- if isinstance(s, str):
- return bytes(s, encoding='utf8')
- else:
- return s
+ return s
def repr_bytes(obj):
"""Return a bytes representation of the object"""
- if sys.version_info[0] == 2:
- return repr(obj)
- else:
- return bytes(obj)
+ return bytes(obj)
class newobject(object):
diff --git a/fastimport/parser.py b/fastimport/parser.py
index 0a88d84..ceee1b4 100644
--- a/fastimport/parser.py
+++ b/fastimport/parser.py
@@ -649,7 +649,7 @@ def _unquote_c_string(s):
codecs.decode(match.group(0), 'unicode-escape')
)
- if sys.version_info[0] >= 3 and isinstance(s, bytes):
+ if isinstance(s, bytes):
return ESCAPE_SEQUENCE_BYTES_RE.sub(decode_match, s)
else:
return ESCAPE_SEQUENCE_RE.sub(decode_match, s)
diff --git a/fastimport/py.typed b/fastimport/py.typed
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fastimport/py.typed