Skip to content

Commit

Permalink
Add workaround for PGO failures with Heroku-22's libexpat
Browse files Browse the repository at this point in the history
  • Loading branch information
edmorley committed Oct 10, 2024
1 parent ebd222f commit 47c9f3a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builds/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RUN apt-get update --error-on=any \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp
COPY build_python_runtime.sh .
COPY build_python_runtime.sh python-3.13-ubuntu-22.04-libexpat-workaround.patch .
8 changes: 8 additions & 0 deletions builds/build_python_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ gpg --batch --verify python.tgz.asc python.tgz
tar --extract --file python.tgz --strip-components=1 --directory "${SRC_DIR}"
cd "${SRC_DIR}"

# Work around PGO profile test failures with Python 3.13 on Ubuntu 22.04, due to the tests
# checking the raw libexpat version which doesn't account for Ubuntu backports:
# https://github.com/heroku/heroku-buildpack-python/pull/1661#issuecomment-2405259352
# https://github.com/python/cpython/issues/125067
if [[ "${PYTHON_MAJOR_VERSION}" == "3.13" && "${STACK}" == "heroku-22" ]]; then
patch -p1 </tmp/python-3.13-ubuntu-22.04-libexpat-workaround.patch
fi

# Aim to keep this roughly consistent with the options used in the Python Docker images,
# for maximum compatibility / most battle-tested build configuration:
# https://github.com/docker-library/python
Expand Down
24 changes: 24 additions & 0 deletions builds/python-3.13-ubuntu-22.04-libexpat-workaround.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index ebec9d8f18a..385735c1e18 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1504,9 +1504,11 @@ def test_simple_xml(self, chunk_size=None, flush=False):
self.assert_event_tags(parser, [('end', 'root')])
self.assertIsNone(parser.close())

+ @unittest.skip('Work around: https://github.com/python/cpython/issues/125067')
def test_simple_xml_chunk_1(self):
self.test_simple_xml(chunk_size=1, flush=True)

+ @unittest.skip('Work around: https://github.com/python/cpython/issues/125067')
def test_simple_xml_chunk_5(self):
self.test_simple_xml(chunk_size=5, flush=True)

@@ -1731,6 +1733,7 @@ def test_flush_reparse_deferral_enabled(self):

self.assert_event_tags(parser, [('end', 'doc')])

+ @unittest.skip('Work around: https://github.com/python/cpython/issues/125067')
def test_flush_reparse_deferral_disabled(self):
parser = ET.XMLPullParser(events=('start', 'end'))

0 comments on commit 47c9f3a

Please sign in to comment.