From cfccd6fe5ae00d7e81cd755be55d51ff3bf17186 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 18 Mar 2023 09:49:51 +0100 Subject: [PATCH] gnu: python-sgmllib3k: Add Python >=3.9 compatibility. * gnu/packages/patches/python-sgmllib3k-assertions.patch: New file. * gnu/local.mk: Register it. * gnu/packages/python-xyz.scm (python-sgmllib3k): Use it. --- gnu/local.mk | 1 + .../patches/python-sgmllib3k-assertions.patch | 221 ++++++++++++++++++ gnu/packages/python-xyz.scm | 3 +- 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/python-sgmllib3k-assertions.patch diff --git a/gnu/local.mk b/gnu/local.mk index ff35978f07..d63e288a48 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1640,6 +1640,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-random2-getrandbits-test.patch \ %D%/packages/patches/python-poppler-qt5-fix-build.patch \ %D%/packages/patches/python-pypdf-annotate-tests-appropriately.patch \ + %D%/packages/patches/python-sgmllib3k-assertions.patch \ %D%/packages/patches/python-telingo-fix-comparison.patch \ %D%/packages/patches/python-w3lib-fix-test-failure.patch \ %D%/packages/patches/sdcc-disable-non-free-code.patch \ diff --git a/gnu/packages/patches/python-sgmllib3k-assertions.patch b/gnu/packages/patches/python-sgmllib3k-assertions.patch new file mode 100644 index 0000000000..872f1c62c9 --- /dev/null +++ b/gnu/packages/patches/python-sgmllib3k-assertions.patch @@ -0,0 +1,221 @@ +Restores compatibility with Python >=3.9, +which removed the custom .error() method in +https://github.com/python/cpython/commit/e34bbfd61f405eef89e8aa50672b0b25022de320 + +Despite the big diff, only a try…except clause is added. + +--- source/sgmllib.py 2023-03-18 08:57:58.726240606 +0100 ++++ source/sgmllib.py 2023-03-18 09:02:01.667568916 +0100 +@@ -101,113 +101,116 @@ + """Handle the remaining data.""" + self.goahead(1) + +- def error(self, message): +- raise SGMLParseError(message) +- + # Internal -- handle data as far as reasonable. May leave state + # and data to be processed by a subsequent call. If 'end' is + # true, force handling all data as if followed by EOF marker. + def goahead(self, end): +- rawdata = self.rawdata +- i = 0 +- n = len(rawdata) +- while i < n: +- if self.nomoretags: +- self.handle_data(rawdata[i:n]) +- i = n +- break +- match = interesting.search(rawdata, i) +- if match: j = match.start() +- else: j = n +- if i < j: +- self.handle_data(rawdata[i:j]) +- i = j +- if i == n: break +- if rawdata[i] == '<': +- if starttagopen.match(rawdata, i): ++ try: ++ rawdata = self.rawdata ++ i = 0 ++ n = len(rawdata) ++ while i < n: ++ if self.nomoretags: ++ self.handle_data(rawdata[i:n]) ++ i = n ++ break ++ match = interesting.search(rawdata, i) ++ if match: j = match.start() ++ else: j = n ++ if i < j: ++ self.handle_data(rawdata[i:j]) ++ i = j ++ if i == n: break ++ if rawdata[i] == '<': ++ if starttagopen.match(rawdata, i): ++ if self.literal: ++ self.handle_data(rawdata[i]) ++ i = i+1 ++ continue ++ k = self.parse_starttag(i) ++ if k < 0: break ++ i = k ++ continue ++ if rawdata.startswith(" (i + 1): ++ self.handle_data("<") ++ i = i+1 ++ else: ++ # incomplete ++ break ++ continue ++ if rawdata.startswith("