diff options
-rw-r--r-- | fastimport/commands.py | 12 | ||||
-rw-r--r-- | fastimport/helpers.py | 17 | ||||
-rw-r--r-- | fastimport/parser.py | 2 | ||||
-rw-r--r-- | fastimport/py.typed | 0 | ||||
-rwxr-xr-x | setup.py | 3 |
5 files changed, 10 insertions, 24 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 @@ -1,5 +1,5 @@ #!/usr/bin/env python -from distutils.core import setup +from setuptools import setup version = "0.9.8" @@ -13,6 +13,7 @@ setup(name="fastimport", license="GNU GPL v2 or later", url="https://github.com/jelmer/python-fastimport", packages=['fastimport', 'fastimport.tests', 'fastimport.processors'], + test_suite="fastimport.tests.test_suite", scripts=[ 'bin/fast-import-query', 'bin/fast-import-filter', |