Skip to content

Commit

Permalink
python35/36: Fix build with expat-2.6.0 (Issue #1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmacks committed Mar 6, 2024
1 parent 4c2c0ab commit 6b5d07e
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff -Nurd Python-3.6.15.orig/Lib/test/test_minidom.py Python-3.6.15/Lib/test/test_minidom.py
--- Python-3.6.15.orig/Lib/test/test_minidom.py 2021-09-03 23:49:41.000000000 -0400
+++ Python-3.6.15/Lib/test/test_minidom.py 2024-03-06 08:41:19.000000000 -0500
@@ -5,10 +5,12 @@
from test import support
import unittest

+import pyexpat
import xml.dom.minidom

from xml.dom.minidom import parse, Node, Document, parseString
from xml.dom.minidom import getDOMImplementation
+from xml.parsers.expat import ExpatError


tstfile = support.findfile("test.xml", subdir="xmltestdata")
@@ -60,17 +62,7 @@
def testDocumentAsyncAttr(self):
doc = Document()
self.assertFalse(doc.async_)
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(getattr(doc, 'async', True))
- with self.assertWarns(DeprecationWarning):
- setattr(doc, 'async', True)
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(getattr(doc, 'async', False))
- self.assertTrue(doc.async_)
-
self.assertFalse(Document.async_)
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(getattr(Document, 'async', True))

def testParseFromBinaryFile(self):
with open(tstfile, 'rb') as file:
@@ -1156,7 +1148,13 @@

# Verify that character decoding errors raise exceptions instead
# of crashing
- self.assertRaises(UnicodeDecodeError, parseString,
+ if pyexpat.version_info >= (2, 4, 5):
+ self.assertRaises(ExpatError, parseString,
+ b'<fran\xe7ais></fran\xe7ais>')
+ self.assertRaises(ExpatError, parseString,
+ b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
+ else:
+ self.assertRaises(UnicodeDecodeError, parseString,
b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')

doc.unlink()
@@ -1602,7 +1600,12 @@
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)

def testExceptionOnSpacesInXMLNSValue(self):
- with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
+ if pyexpat.version_info >= (2, 4, 5):
+ context = self.assertRaisesRegex(ExpatError, 'syntax error')
+ else:
+ context = self.assertRaisesRegex(ValueError, 'Unsupported syntax')
+
+ with context:
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')

def testDocRemoveChild(self):
25 changes: 20 additions & 5 deletions 10.9-libcxx/stable/main/finkinfo/languages/python35.info
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@ BuildDepends: <<
libgettext8-dev,
liblzma5,
libncursesw5,
readline8,
sqlite3-dev (>= 3.30.1-1),
openssl110-dev (>= 1.1.1d-1),
pkgconfig,
readline8,
sqlite3-dev (>= 3.30.1-1),
tcltk-dev (>= 8.4.1-1),
x11-dev
<<
# Python 3.4+ wants to install these packages but that conflicts with fink's.
Recommends: pip-py%type_pkg[python], setuptools-tng-py%type_pkg[python]

Provides: argparse-py%type_pkg[python], futures-py%type_pkg[python], enum34-py%type_pkg[python], pathlib-py%type_pkg[python]
Recommends: <<
pip-py%type_pkg[python],
setuptools-tng-py%type_pkg[python]
<<
Provides: <<
argparse-py%type_pkg[python],
enum34-py%type_pkg[python],
futures-py%type_pkg[python],
pathlib-py%type_pkg[python]
<<

Source: https://www.python.org/ftp/python/%v/Python-%v.tar.xz
Source-Checksum: SHA256(0f0fa8685c1dc1f1dacb0b4e7779796b90aef99dc1fa4967a71b9da7b57d4a28)
Expand All @@ -57,10 +64,15 @@ PatchFile: %n.patch
PatchFile-MD5: f07ce62c88ca3be5afd05362a935f0a6
PatchFile2: %n-darwin20.patch
PatchFile2-MD5: 5fc4c8c53d930e55ec850bb3bc9cccbf
# Backport from python-3.7.13
PatchFile3: %n-expat26_minidom.patch
PatchFile3-MD5: 0da4dcad429595130d54a0e2b9b93542

PatchScript: <<
#!/bin/sh -ex
sed 's|@PREFIX@|%p|g' < %{PatchFile} | patch -p1
patch -p1 < %{PatchFile2}
patch -p1 < %{PatchFile3}
# /tmp and /var/tmp are symlinks to /private/tmp and /private/var/tmp
# on OS X. That's fine except it can cause tests in some packages to
# fail since '/tmp' != '/private/tmp'. Default to using /private/tmp.
Expand Down Expand Up @@ -137,6 +149,9 @@ InfoTest: <<
# the other 4 hang indefinitely
# test_ctypes is currently broken on 11.0
EXTRATESTOPTS='-w -unone -x test_socket test_distutils test_ssl test_multiprocessing_spawn test_asyncio test_httpservers test_logging test_xmlrpc test_ctypes'
# Test broken by expat-2.6, hard to backport patches to it
# from newer pythonXX (see fink issue #1129)
EXTRATESTOPTS="$EXTRATESTOPTS -x test_xml_etree test_xml_etree_c"
LANG=en_US.UTF-8 make -k test EXTRATESTOPTS="$EXTRATESTOPTS" || TESTRETURN=$?

# Put install_name back.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff -Nurd Python-3.6.15.orig/Lib/test/test_minidom.py Python-3.6.15/Lib/test/test_minidom.py
--- Python-3.6.15.orig/Lib/test/test_minidom.py 2021-09-03 23:49:41.000000000 -0400
+++ Python-3.6.15/Lib/test/test_minidom.py 2024-03-06 08:41:19.000000000 -0500
@@ -5,10 +5,12 @@
from test import support
import unittest

+import pyexpat
import xml.dom.minidom

from xml.dom.minidom import parse, Node, Document, parseString
from xml.dom.minidom import getDOMImplementation
+from xml.parsers.expat import ExpatError


tstfile = support.findfile("test.xml", subdir="xmltestdata")
@@ -60,17 +62,7 @@
def testDocumentAsyncAttr(self):
doc = Document()
self.assertFalse(doc.async_)
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(getattr(doc, 'async', True))
- with self.assertWarns(DeprecationWarning):
- setattr(doc, 'async', True)
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(getattr(doc, 'async', False))
- self.assertTrue(doc.async_)
-
self.assertFalse(Document.async_)
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(getattr(Document, 'async', True))

def testParseFromBinaryFile(self):
with open(tstfile, 'rb') as file:
@@ -1156,7 +1148,13 @@

# Verify that character decoding errors raise exceptions instead
# of crashing
- self.assertRaises(UnicodeDecodeError, parseString,
+ if pyexpat.version_info >= (2, 4, 5):
+ self.assertRaises(ExpatError, parseString,
+ b'<fran\xe7ais></fran\xe7ais>')
+ self.assertRaises(ExpatError, parseString,
+ b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
+ else:
+ self.assertRaises(UnicodeDecodeError, parseString,
b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')

doc.unlink()
@@ -1602,7 +1600,12 @@
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)

def testExceptionOnSpacesInXMLNSValue(self):
- with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
+ if pyexpat.version_info >= (2, 4, 5):
+ context = self.assertRaisesRegex(ExpatError, 'syntax error')
+ else:
+ context = self.assertRaisesRegex(ValueError, 'Unsupported syntax')
+
+ with context:
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')

def testDocRemoveChild(self):
25 changes: 20 additions & 5 deletions 10.9-libcxx/stable/main/finkinfo/languages/python36.info
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@ BuildDepends: <<
libgettext8-dev,
liblzma5,
libncursesw5,
readline8,
sqlite3-dev (>= 3.30.1-1),
openssl110-dev (>= 1.1.1g-1),
pkgconfig,
readline8,
sqlite3-dev (>= 3.30.1-1),
tcltk-dev (>= 8.4.1-1),
x11-dev
<<
# Python 3.4+ wants to install these packages but that conflicts with fink's.
Recommends: pip-py%type_pkg[python], setuptools-tng-py%type_pkg[python]

Provides: argparse-py%type_pkg[python], futures-py%type_pkg[python], enum34-py%type_pkg[python], pathlib-py%type_pkg[python]
Recommends: <<
pip-py%type_pkg[python],
setuptools-tng-py%type_pkg[python]
<<
Provides: <<
argparse-py%type_pkg[python],
enum34-py%type_pkg[python],
futures-py%type_pkg[python],
pathlib-py%type_pkg[python]
<<

Source: https://www.python.org/ftp/python/%v/Python-%v.tar.xz
Source-Checksum: SHA256(6e28d7cdd6dd513dd190e49bca3972e20fcf455090ccf2ef3f1a227614135d91)
Expand All @@ -55,10 +62,15 @@ PatchFile: %n.patch
PatchFile-MD5: d1f5d23c7ee06375a290374404552ecb
PatchFile2: %n-darwin20.patch
PatchFile2-MD5: ce2e335a3d3964002ef12219e7ed56ae
# Backport from python-3.7.13
PatchFile3: %n-expat26_minidom.patch
PatchFile3-MD5: 0da4dcad429595130d54a0e2b9b93542

PatchScript: <<
#!/bin/sh -ex
sed 's|@PREFIX@|%p|g' < %{PatchFile} | patch -p1
patch -p1 < %{PatchFile2}
patch -p1 < %{PatchFile3}
# /tmp and /var/tmp are symlinks to /private/tmp and /private/var/tmp
# on OS X. That's fine except it can cause tests in some packages to
# fail since '/tmp' != '/private/tmp'. Default to using /private/tmp.
Expand Down Expand Up @@ -137,6 +149,9 @@ InfoTest: <<
# test_distutils requires an installed python36 instance for linking
# test_ctypes is currently broken on 11.0
EXTRATESTOPTS='-w -unone -x test_socket test_asyncio test_httpservers test_logging test_xmlrpc test_distutils test_ctypes'
# Test broken by expat-2.6, hard to backport patches to it
# from newer pythonXX (see fink issue #1129)
EXTRATESTOPTS="$EXTRATESTOPTS -x test_xml_etree test_xml_etree_c"
LANG=en_US.UTF-8 make -k test EXTRATESTOPTS="$EXTRATESTOPTS" || TESTRETURN=$?

# Put install_name back.
Expand Down

0 comments on commit 6b5d07e

Please sign in to comment.