diff --git a/.gitignore b/.gitignore index eb84923..60a16f2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ recode-3.6.tar.gz /recode-3.7.2.tar.gz /recode-3.7.3.tar.gz /recode-3.7.4.tar.gz +/recode-3.7.5.tar.gz diff --git a/recode-3.7.1-python-3-compatibility.patch b/recode-3.7.1-python-3-compatibility.patch deleted file mode 100644 index 8fcd8ae..0000000 --- a/recode-3.7.1-python-3-compatibility.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 98a1eff200a60d81f404b2874db24a88ee2a592f Mon Sep 17 00:00:00 2001 -From: Shlomi Fish -Date: Tue, 25 Jun 2019 12:23:39 +0300 -Subject: [PATCH] python 3 compatibility. -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -See https://github.com/rrthomas/recode/issues/15 . - -Petr Pisar: Ported to 3.7.1 from py3-take2 branch of -: - - commit 04aefb26fa080c8e9d6ba7a136a8ae263727fba8 - Author: Shlomi Fish - Date: Tue Jun 25 12:23:39 2019 +0300 - -Signed-off-by: Petr Písař ---- - tables.py | 59 +++++++++++++++++++++++++++++++++++-------------------- - 1 file changed, 38 insertions(+), 21 deletions(-) - -diff --git a/tables.py b/tables.py -index 2604dfe..51752a6 100755 ---- a/tables.py -+++ b/tables.py -@@ -43,6 +43,16 @@ When `-F' and `-n' are used, process Alain's tables. - - import re, sys - -+def to_unicode(s): -+ import six -+ if isinstance(s, six.text_type): -+ return s -+ try: -+ s = six.text_type(s, 'utf-8') -+ except UnicodeDecodeError as err: -+ s = six.text_type(s, 'utf-8', 'ignore') -+ return s -+ - # Character constants. - REPLACEMENT_CHARACTER = 0xFFFD - NOT_A_CHARACTER = 0xFFFF -@@ -127,7 +137,7 @@ class Main: - self.mnemonics = Mnemonics() - self.mnemonics.digest_mnemonics_ds(input) - break -- if input.match('Network Working Group +K\. Simonsen$'): -+ if input.match('Network Working Group +K\\. Simonsen$'): - if (self.charnames - and self.charnames.do_sources - and not French_option): -@@ -201,12 +211,15 @@ class Charnames(Options): - - def digest_french(self, input): - self.preset_french() -- fold_table = range(256) -- for before, after in map( -- None, -+ fold_table = list(range(256)) -+ def myord(c): -+ if isinstance(c, int): -+ return c -+ return ord(c) -+ for before, after in zip( - u'ABCDEFGHIJKLMNOPQRSTUVWXYZÀÂÇÈÉÊÎÏÑÔÖÛ'.encode('ISO-8859-1'), - u'abcdefghijklmnopqrstuvwxyzàâçèéêîïñôöû'.encode('ISO-8859-1')): -- fold_table[ord(before)] = ord(after) -+ fold_table[myord(before)] = myord(after) - folding = ''.join(map(chr, fold_table)) - ignorables = ( - u''.encode('ISO-8859-1'), -@@ -314,6 +327,8 @@ class Charnames(Options): - if len(text) > self.max_length: - self.max_length = len(text) - for word in text.split(): -+ word = to_unicode(word) -+ assert isinstance(word, str) - self.code_map[word] = self.code_map.get(word, 0) + 1 - - def presort_word(self, word): -@@ -334,18 +349,18 @@ class Charnames(Options): - # the second cycling faster from 1 to 255. - if run.verbose: - sys.stdout.write(' sorting words...') -- pairs = map(self.presort_word, self.code_map.keys()) -+ pairs = list(map(self.presort_word, self.code_map.keys())) - pairs.sort() -- words = map(lambda pair: pair[1], pairs) -+ words = list(map(lambda pair: pair[1], pairs)) - pairs = None - if run.verbose: - sys.stdout.write(' %d of them\n' % len(words)) - count = len(words) -- singles = (255 * 255 - count) / 254 -+ singles = (255 * 255 - count) // 254 - # Transmit a few values for further usage by the C code. - if run.verbose: - sys.stdout.write(' sorting names...') -- ucs2_table = self.charname_map.keys() -+ ucs2_table = list(self.charname_map.keys()) - ucs2_table.sort() - if run.verbose: - sys.stdout.write(' %d of them\n' % len(ucs2_table)) -@@ -366,12 +381,14 @@ class Charnames(Options): - word = words[counter] - write(' %-28s/* \\%0.3o */\n' - % ('"%s",' % re.sub('"', r'\"', word), char1)) -+ assert isinstance(word, str) - self.code_map[words[counter]] = char1 - char1 += 1 - for counter in range(singles, count): - word = words[counter] - write(' %-28s/* \\%0.3o\\%0.3o */\n' - % ('"%s",' % re.sub('"', r'\"', word, 1), char1, char2)) -+ assert isinstance(word, str) - self.code_map[words[counter]] = 256 * char1 + char2 - if char2 == 255: - char1 += 1 -@@ -397,7 +414,7 @@ class Charnames(Options): - if code < 256: - write('\\%0.3o' % code) - else: -- write('\\%0.3o\\%0.3o' % (code / 256, code % 256)) -+ write('\\%0.3o\\%0.3o' % (code // 256, code % 256)) - else: - sys.stdout.write('??? %s\n' % word) - write('"},\n') -@@ -540,7 +557,7 @@ class Mnemonics(Options): - continue - if len(line) == 3: - continue -- if input.begins(' \.\.\.'): -+ if input.begins(' \\.\\.\\.'): - continue - if line == ' Presentation forms\n': - continue -@@ -667,7 +684,7 @@ class Mnemonics(Options): - 'static const struct entry table[TABLE_LENGTH] =\n' - ' {\n') - count = 0 -- indices = self.mnemonic_map.keys() -+ indices = list(self.mnemonic_map.keys()) - indices.sort() - for ucs2 in indices: - text = self.mnemonic_map[ucs2] -@@ -681,7 +698,7 @@ class Mnemonics(Options): - 'static const unsigned short inverse[TABLE_LENGTH] =\n' - ' {') - count = 0 -- keys = inverse_map.keys() -+ keys = list(inverse_map.keys()) - keys.sort() - for text in keys: - if count % 10 == 0: -@@ -744,7 +761,7 @@ class Strips(Options): - def digest_rfc1345(self, input): - self.init_write_data() - # Informal canonical order of presentation. -- CHARSET, REM, ALIAS, ESC, BITS, CODE = range(6) -+ CHARSET, REM, ALIAS, ESC, BITS, CODE = list(range(6)) - charset = None - skip = False - while True: -@@ -956,7 +973,7 @@ class Strips(Options): - if input.search('\032'): - # Old MS-DOS C-z !! - break -- match = input.match('0x([0-9A-F]+)\t0x([0-9A-F]+)\t\#') -+ match = input.match('0x([0-9A-F]+)\t0x([0-9A-F]+)\t#') - if match: - self.table[int(match.group(1), 16)] = int(match.group(2), 16) - else: -@@ -1125,7 +1142,7 @@ class Strips(Options): - write = Output('fr-%s' % self.TEXINFO, noheader=True).write - else: - write = Output(self.TEXINFO, noheader=True).write -- charsets = self.remark_map.keys() -+ charsets = list(self.remark_map.keys()) - charsets.sort() - for charset in charsets: - write('\n' -@@ -1161,12 +1178,12 @@ class Input: - - def __init__(self, name): - self.name = name -- self.input = file(name) -+ self.input = open(name, "rb") - self.line_count = 0 - sys.stdout.write("Reading %s\n" % name) - - def readline(self): -- self.line = self.input.readline() -+ self.line = to_unicode(self.input.readline()) - self.line_count += 1 - return self.line - -@@ -1184,16 +1201,16 @@ class Input: - return self.line[:len(text)] == text - - def match(self, pattern): -- return re.match(pattern, self.line) -+ return re.match(pattern, to_unicode(self.line)) - - def search(self, pattern): -- return re.search(pattern, self.line) -+ return re.search(pattern, to_unicode(self.line)) - - class Output: - - def __init__(self, name, noheader=False): - self.name = name -- self.write = file(name, 'w').write -+ self.write = open(name, 'w').write - sys.stdout.write("Writing %s\n" % name) - if not noheader: - self.write("""\ --- -2.21.0 - diff --git a/recode-3.7.4-Port-other-tests-to-Python-3.patch b/recode-3.7.4-Port-other-tests-to-Python-3.patch deleted file mode 100644 index 4b4bcf2..0000000 --- a/recode-3.7.4-Port-other-tests-to-Python-3.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 72564d53c8c841f2a13d2a0cc6a38910b36bb306 Mon Sep 17 00:00:00 2001 -From: perl-Git-CPAN-Patch Owner -Date: Fri, 16 Aug 2019 12:43:18 +0200 -Subject: [PATCH] Port other tests to Python 3 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Ported to 3.7.4. - -Signed-off-by: Petr Písař ---- - tests/pytest | 8 ++++---- - tests/t50_methods.py | 8 ++++---- - tests/t90_bigauto.py | 4 ++-- - 3 files changed, 10 insertions(+), 10 deletions(-) - -diff --git a/tests/pytest b/tests/pytest -index 4489592..8e39d2a 100755 ---- a/tests/pytest -+++ b/tests/pytest -@@ -41,7 +41,7 @@ least one such failed test, the return status of this program is non-zero. - - __metaclass__ = type - import inspect, os, sys, time, traceback --from StringIO import StringIO -+from io import StringIO - - # How many displayable characters in an output line. - WIDTH = 79 -@@ -155,7 +155,7 @@ class Main: - else: - text = u' ' + text - write(text + u'\n') -- except Exit, exception: -+ except Exit as exception: - if not self.verbose: - write(u'\n') - write(u'\n* %s *\n' % str(exception)) -@@ -270,7 +270,7 @@ class Main: - if minimum is not None: - collection.append((minimum, name, objet, False)) - elif name.startswith(u'test_') and inspect.isfunction(objet): -- code = objet.func_code -+ code = objet.__code__ - collection.append((code.co_firstlineno, name, objet, - bool(code.co_flags & 32))) - if not collection: -@@ -316,7 +316,7 @@ class Main: - # FIXME: Should likely do class setup here. - try: - for counter, arguments in enumerate(function()): -- collection.append((prefix + u'/' + unicode(counter + 1), -+ collection.append((prefix + u'/' + str(counter + 1), - arguments[0], arguments[1:])) - except Skipped: - return -diff --git a/tests/t50_methods.py b/tests/t50_methods.py -index 696bb28..aaf3997 100644 ---- a/tests/t50_methods.py -+++ b/tests/t50_methods.py -@@ -5,7 +5,7 @@ from __main__ import py - - import os, sys - input_name = '%s/../COPYING' % os.path.dirname(sys.argv[0]) --input = file(input_name, 'rb').read() -+input = open(input_name, 'rb').read() - - def test_1(): - # No step at all. -@@ -41,7 +41,7 @@ def validate(request): - command = ('$R --quiet --force < %s %s' - '| $R --quiet --force %s..%s' - % (input_name, request, after, before)) -- print command -+ print(command) - output = common.external_output(command) - common.assert_or_diff(output, input) - -@@ -51,8 +51,8 @@ def validate(request): - % (request, common.run.work)) - command2 = ('$R --quiet --force %s..%s %s' - % (after, before, common.run.work)) -- print command1 -- print command2 -+ print(command1) -+ print(command2) - common.external_output(command1) - common.external_output(command2) - output = file(common.run.work, 'rb').read() -diff --git a/tests/t90_bigauto.py b/tests/t90_bigauto.py -index 861cce6..46d4cd4 100644 ---- a/tests/t90_bigauto.py -+++ b/tests/t90_bigauto.py -@@ -57,7 +57,7 @@ class Test: - # consider as a single test, one "before" against all "after"s. - # However, without a Recode module, we do not know how many - # "before"s exist, and the skip count is then rather small. -- print before -+ print(before) - for after in self.charsets: - if after is not before: - request = Recode.Request(self.outer) -@@ -97,7 +97,7 @@ class Report: - line = readline() - if line: - if len(line[:-lensep].split(':', 1)) != 2: -- print '*', line, -+ print('*', line) - type, shrunk_to = line[:-lensep].split(':', 1) - if type == 'Shrunk to': - steps = self.get_steps(shrunk_to) --- -2.21.0 - diff --git a/recode.spec b/recode.spec index 1d5ef9d..50d2549 100644 --- a/recode.spec +++ b/recode.spec @@ -1,10 +1,8 @@ # Use valgrind in tests. Very slow. Some leaks in Python. %bcond_with recode_enables_valgrind_test -# Use Python3 for tests. Not yet fully ported. -%bcond_with recode_enables_python3_test Name: recode -Version: 3.7.4 +Version: 3.7.5 Release: 1%{?dist} Summary: Conversion between character sets and surfaces # COPYING: GPLv3 text @@ -60,12 +58,6 @@ URL: https://github.com/rrthomas/recode Source: %{url}/releases/download/v%{version}/recode-%{version}.tar.gz # Make internal hash function identifiers unique Patch0: recode-3.7.1-Rename-coliding-hash-functions.patch -# 1/2 Adapt tests to Python3, unfinished, -# -Patch1: recode-3.7.1-python-3-compatibility.patch -# 2/2 Adapt tests to Python3, unfinished, -# -Patch2: recode-3.7.4-Port-other-tests-to-Python-3.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: coreutils @@ -79,11 +71,7 @@ BuildRequires: libtool BuildRequires: texinfo # Tests: BuildRequires: python3-Cython -%if %{with recode_enables_python3_test} -BuildRequires: python3-devel -%else -BuildRequires: python2-devel -%endif +BuildRequires: python3-devel >= 3.7.5 %if %{with recode_enables_valgrind_test} # Optional tests: BuildRequires: valgrind @@ -108,18 +96,10 @@ This package provides deader files for recode library. %prep %setup -q %patch0 -p1 -%if %{with recode_enables_python3_test} -%patch1 -p1 -%patch2 -p1 -%endif autoreconf -fi %build -%if %{with recode_enables_python3_test} export PYTHON=%{__python3} -%else -export PYTHON=%{__python2} -%endif %configure \ --without-dmalloc \ --disable-gcc-warnings \ @@ -163,6 +143,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la %{_includedir}/* %changelog +* Thu Sep 12 2019 Petr Pisar - 3.7.5-1 +- 3.7.5 bump + * Mon Sep 02 2019 Petr Pisar - 3.7.4-1 - 3.7.4 bump diff --git a/sources b/sources index 1a0f046..3e17582 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (recode-3.7.4.tar.gz) = 1ef2b60508d9cd84235fe5ae74d12eee6bd2987695871c4ba9c9111532a9c2638f2f6a5ab77eec7e3774b09f0e0a5d0555a2d2e21c94e5a6a0e7a4b0df9da79c +SHA512 (recode-3.7.5.tar.gz) = bb18b5acbf1bb00f5dd829dd18ccbabeb8224bd85479759d1745bb259e91b0cef01af0ada8471e89de6aedf3ffa8799cc9caa068030b1b25995ec806094f4450