diff --git a/python-docutils.spec b/python-docutils.spec index af4d89b..e717ee2 100644 --- a/python-docutils.spec +++ b/python-docutils.spec @@ -8,6 +8,9 @@ License: Public Domain and BSD and Python and GPLv3+ URL: https://docutils.sourceforge.net Source0: https://sourceforge.net/projects/docutils/files/docutils/%{version}/docutils-%{version}.tar.gz +# https://sourceforge.net/p/docutils/bugs/436/ +Patch1: python3.11-skip-null-bytes-exception-test.patch + BuildArch: noarch BuildRequires: pyproject-rpm-macros @@ -34,7 +37,7 @@ Summary: %{summary} %prep -%autosetup -n docutils-%{version} +%autosetup -p1 -n docutils-%{version} # Remove shebang from library files sed -i -e '/#! *\/usr\/bin\/.*/{1D}' $(grep -Erl '^#!.+python' docutils) diff --git a/python3.11-skip-null-bytes-exception-test.patch b/python3.11-skip-null-bytes-exception-test.patch new file mode 100644 index 0000000..8211578 --- /dev/null +++ b/python3.11-skip-null-bytes-exception-test.patch @@ -0,0 +1,88 @@ +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 2e11131..cf9f097 100755 +--- a/test/test_parsers/test_rst/test_directives/test_tables.py ++++ b/test/test_parsers/test_rst/test_directives/test_tables.py +@@ -55,17 +55,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'] = [ +@@ -1025,26 +1014,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 +@@ -1459,6 +1428,38 @@ 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