Skip to content

Commit f64eb50

Browse files
authored
reduce extra code for python 2 compatibility
1 parent 9a21673 commit f64eb50

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

tests/test_entry.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import locale
88
from os import environ, stat
99
from os.path import join
10-
import sys
1110
import unicodedata
1211

1312
from libarchive import memory_reader, memory_writer
1413

1514
from . import data_dir, get_entries, get_tarinfos
1615

1716

17+
text_type = unicode if str is bytes else str # noqa: F821
18+
1819
locale.setlocale(locale.LC_ALL, '')
1920

2021
# needed for sane time stamp comparison
@@ -98,10 +99,6 @@ def check_entries(test_file, regen=False, ignore=''):
9899
# Normalize all unicode (can vary depending on the system)
99100
for d in (e1, e2):
100101
for key in d:
101-
if sys.version_info[0] < 3:
102-
IS_UNICODE = isinstance(d[key], unicode) # noqa: F821
103-
else:
104-
IS_UNICODE = isinstance(d[key], str)
105-
if IS_UNICODE:
102+
if isinstance(d[key], text_type):
106103
d[key] = unicodedata.normalize('NFC', d[key])
107104
assert e1 == e2

0 commit comments

Comments
 (0)