From c1db0bae025e24f3827e7753fc8855ff183a05a5 Mon Sep 17 00:00:00 2001 From: tzing_t Date: Tue, 5 Nov 2024 02:29:44 +0000 Subject: [PATCH] Fix build error, skip null-bytes exeception tests on py3.11 --- python-docutils.spec | 8 +- ...ull-bytes_exeception_tests_on_py3.11.patch | 87 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 skip_null-bytes_exeception_tests_on_py3.11.patch diff --git a/python-docutils.spec b/python-docutils.spec index d7cf02a..99ec974 100644 --- a/python-docutils.spec +++ b/python-docutils.spec @@ -4,15 +4,16 @@ Name: python-%{modname} Version: 0.16 -Release: 5 +Release: 6 Summary: Documentation Utilities Written in Python, for General- and Special-Purpose Use License: Public Domain and BSD and Python and GPLv3+ URL: http://docutils.sourceforge.net -Source0: http://downloads.sourceforge.net/docutils/docutils-0.16.tar.gz +Source0: https://files.pythonhosted.org/packages/2f/e0/3d435b34abd2d62e8206171892f174b180cd37b09d57b924ca5c2ef2219d/docutils-0.16.tar.gz BuildArch: noarch BuildRequires: python3-devel Patch0000: fix-test-error.patch +Patch0001: skip_null-bytes_exeception_tests_on_py3.11.patch %global _description \ Docutils is an open-source text processing system for processing plaintext\ @@ -94,6 +95,9 @@ popd %doc THANKS.txt docs tools/editors %changelog +* Tue Nov 05 2024 tzing - 0.16-6 +- Fix build error, skip null-bytes exeception tests on py3.11 + * Mon Nov 2 2020 wangjie -0.16-5 - Type:NA - ID:NA diff --git a/skip_null-bytes_exeception_tests_on_py3.11.patch b/skip_null-bytes_exeception_tests_on_py3.11.patch new file mode 100644 index 0000000..c310a2e --- /dev/null +++ b/skip_null-bytes_exeception_tests_on_py3.11.patch @@ -0,0 +1,87 @@ +diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py +index 394ac2c..85b14aa 100755 +--- a/test/test_parsers/test_rst/test_directives/test_tables.py ++++ b/test/test_parsers/test_rst/test_directives/test_tables.py +@@ -52,17 +52,6 @@ csv_unknown_url = "'bogus.csv'" + if sys.version_info < (3, 0): + csv_unknown_url = "bogus.csv" + +- +-def null_bytes(): +- with open(utf_16_csv, 'rb') as f: +- csv_data = f.read() +- csv_data = unicode(csv_data, 'latin1').splitlines() +- reader = csv.reader([tables.CSVTable.encode_for_csv(line + '\n') +- for line in csv_data]) +- next(reader) +- +-null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0] +- + totest = {} + + totest['table'] = [ +@@ -1022,26 +1011,6 @@ u"""\ + good, csv, data + """ % csv_eod_error_str], + ["""\ +-.. csv-table:: bad encoding +- :file: %s +- :encoding: latin-1 +- +-(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) +-""" % utf_16_csv, +-"""\ +- +- +- +- Error with CSV data in "csv-table" directive: +- %s +- +- .. csv-table:: bad encoding +- :file: %s +- :encoding: latin-1 +- +- (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) +-""" % (null_bytes_exception, utf_16_csv)], +-["""\ + .. csv-table:: good encoding + :file: %s + :encoding: utf-16 +@@ -1456,6 +1425,37 @@ totest['list-table'] = [ + """], + ] + ++if sys.version_info < (3, 11): ++ def null_bytes(): ++ with open(utf_16_csv, 'rb') as f: ++ csv_data = f.read() ++ csv_data = unicode(csv_data, 'latin1').splitlines() ++ reader = csv.reader([tables.CSVTable.encode_for_csv(line + '\n') ++ for line in csv_data]) ++ next(reader) ++ ++ null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0] ++ ++ totest['table'].append(["""\ ++.. csv-table:: bad encoding ++ :file: %s ++ :encoding: latin-1 ++ ++(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) ++""" % utf_16_csv, ++"""\ ++ ++ ++ ++ Error with CSV data in "csv-table" directive: ++ %s ++ ++ .. csv-table:: bad encoding ++ :file: %s ++ :encoding: latin-1 ++ ++ (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.) ++""" % (null_bytes_exception, utf_16_csv)]) + + if __name__ == '__main__': + import unittest -- Gitee