summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@jelmer.uk>2021-04-10 15:25:19 +0100
committerJelmer Vernooij <jelmer@jelmer.uk>2021-04-10 15:25:19 +0100
commitda4b711c897b47903a3ecb3064b2f42ef0c24d5b (patch)
treeed5ce9bf88a809c9f826c03274cd3cee71a1d2dd
parent0107b92042bc1b03db2ea1c38b4e5439e2c6866b (diff)
downloadpython-fastimport-git-da4b711c897b47903a3ecb3064b2f42ef0c24d5b.tar.gz
Drop more python2 support.
-rw-r--r--fastimport/commands.py12
-rw-r--r--fastimport/helpers.py17
-rw-r--r--fastimport/parser.py2
-rw-r--r--fastimport/py.typed0
-rwxr-xr-xsetup.py3
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
diff --git a/setup.py b/setup.py
index b8c5320..6a57c41 100755
--- a/setup.py
+++ b/setup.py
@@ -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',