summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaz Solc <tomaz.solc@tablix.org>2021-02-05 13:36:33 +0100
committerTomaz Solc <tomaz.solc@tablix.org>2021-02-05 14:09:02 +0100
commit4ee4df1c3cc5e3d774c2115140613f057b2e455a (patch)
tree6d28affbee02d9ba49ba38e6ec29364201545591
parent96266a13f0973b2ea4ef7dd2262f45a1bcdf6291 (diff)
downloadunidecode-4ee4df1c3cc5e3d774c2115140613f057b2e455a.tar.gz
More Python 2 compatibility code clean up.
-rw-r--r--tests/test_utility.py4
-rw-r--r--unidecode/__init__.py1
-rw-r--r--unidecode/util.py13
3 files changed, 2 insertions, 16 deletions
diff --git a/tests/test_utility.py b/tests/test_utility.py
index 7a58888..04d31bb 100644
--- a/tests/test_utility.py
+++ b/tests/test_utility.py
@@ -10,10 +10,6 @@ import re
here = os.path.dirname(__file__)
-# Python 2.7 does not have assertRegex
-if not hasattr(unittest.TestCase, 'assertRegex'):
- unittest.TestCase.assertRegex = lambda self, text, exp: self.assertTrue(re.search(exp, text))
-
def get_cmd():
sys_path = os.path.join(here, "..")
diff --git a/unidecode/__init__.py b/unidecode/__init__.py
index 20a8c43..e019972 100644
--- a/unidecode/__init__.py
+++ b/unidecode/__init__.py
@@ -17,7 +17,6 @@ A standard string object will be returned. If you need bytes, use:
b'Knosos'
"""
import warnings
-from sys import version_info
from typing import Optional
Cache = {}
diff --git a/unidecode/util.py b/unidecode/util.py
index 2e14f1a..415bd7b 100644
--- a/unidecode/util.py
+++ b/unidecode/util.py
@@ -1,5 +1,4 @@
# vim:ts=4 sw=4 expandtab softtabstop=4
-from __future__ import print_function
import argparse
import locale
import os
@@ -7,8 +6,6 @@ import sys
from unidecode import unidecode
-PY3 = sys.version_info[0] >= 3
-
def fatal(msg):
sys.stderr.write(msg + "\n")
sys.exit(1)
@@ -36,19 +33,13 @@ def main():
with open(args.path, 'rb') as f:
stream = f.read()
elif args.text:
- if PY3:
- stream = os.fsencode(args.text)
- else:
- stream = args.text
+ stream = os.fsencode(args.text)
# add a newline to the string if it comes from the
# command line so that the result is printed nicely
# on the console.
stream += b'\n'
else:
- if PY3:
- stream = sys.stdin.buffer.read()
- else:
- stream = sys.stdin.read()
+ stream = sys.stdin.buffer.read()
try:
stream = stream.decode(encoding)