gh-121735: Fix module-adjacent references in zip files#123037
Conversation
|
Note that a lot of refactoring happened in the test suite to enable testing this behavior. The history of the refactoring can be found in python/importlib_resources@f77da58...23afc90. These changes were released with |
Sorry, something went wrong.
|
I'm a little apprehensive about the prospect of backporting this to Python 3.12, given the amount of refactoring that had to happen in the tests to make them viable. I may opt to backport the fix but limit the amount of changes backported to the tests, depending on how complicated it turns out to be. |
Sorry, something went wrong.
FFY00
left a comment
There was a problem hiding this comment.
This looks okay to me.
I don't really have any strong opinion regarding backporting the changes to 3.12. I agree it would be nicer to backport without the large test suite refactoring, but that isn't unreasonable to me if the changes don't end up applying cleanly. Not backporting the test suite changes also increases the possibility for test suite bugs to sneak into the 3.12 branch, as that won't be maintained as closely as the main branch. Additionally, it can also cause conflicts when backporting other fixes, so, eh, I guess I am +0.5 on backporting this PR as a whole.
Sorry, something went wrong.
|
@Gatsik - the implementation provided herein has already been reviewed and released as
It's not obvious to me from this fix what the failure mode is. I think I see it now - if the |
Sorry, something went wrong.
Sorry, something went wrong.
|
Thanks @jaraco for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, something went wrong.
…H-123037) * pythongh-116608: Apply style and compatibility changes from importlib_metadata. * pythongh-121735: Ensure module-adjacent resources are loadable from a zipfile. * pythongh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused. (cherry picked from commit ba687d9) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
|
Sorry, @jaraco, I could not cleanly backport this to |
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x RHEL9 Refleaks 3.x has failed when building commit ba687d9. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1589/builds/145 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 144, in test_open_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
f.read(),
^^^^^^^^^
...<2 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_read.py", line 46, in test_read_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 92, in test_read_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
resources.read_text(
^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.refleak/build/Lib/test/test_importlib/resources/test_open.py", line 49, in test_open_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x RHEL8 Refleaks 3.x has failed when building commit ba687d9. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/75/builds/1345 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_open.py", line 49, in test_open_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 92, in test_read_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
resources.read_text(
^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 144, in test_open_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
f.read(),
^^^^^^^^^
...<2 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/test_importlib/resources/test_read.py", line 46, in test_read_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora Refleaks 3.x has failed when building commit ba687d9. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/433/builds/1320 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_read.py", line 46, in test_read_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_open.py", line 49, in test_open_text_with_errors
self.assertEqual(
~~~~~~~~~~~~~~~~^
result,
^^^^^^^
...<2 lines>...
'\x00w\x00o\x00r\x00l\x00d\x00!\x00\n\x00',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 92, in test_read_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
resources.read_text(
^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 144, in test_open_text
self.assertEndsWith( # ignore the BOM
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
f.read(),
^^^^^^^^^
...<2 lines>...
),
^^
)
^
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_importlib/resources/test_functional.py", line 50, in assertEndsWith
self.assertEqual(string[-len(suffix) :], suffix)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
- �H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
? -
+ H�e�l�l�o�,� �U�T�F�-�1�6� �w�o�r�l�d�!�
-
+ �
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot PPC64LE RHEL8 Refleaks 3.x has failed when building commit ba687d9. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/384/builds/1280 Summary of the results of the build (if available): Click to see traceback logsremote: Enumerating objects: 27, done.
remote: Counting objects: 4% (1/24)
remote: Counting objects: 8% (2/24)
remote: Counting objects: 12% (3/24)
remote: Counting objects: 16% (4/24)
remote: Counting objects: 20% (5/24)
remote: Counting objects: 25% (6/24)
remote: Counting objects: 29% (7/24)
remote: Counting objects: 33% (8/24)
remote: Counting objects: 37% (9/24)
remote: Counting objects: 41% (10/24)
remote: Counting objects: 45% (11/24)
remote: Counting objects: 50% (12/24)
remote: Counting objects: 54% (13/24)
remote: Counting objects: 58% (14/24)
remote: Counting objects: 62% (15/24)
remote: Counting objects: 66% (16/24)
remote: Counting objects: 70% (17/24)
remote: Counting objects: 75% (18/24)
remote: Counting objects: 79% (19/24)
remote: Counting objects: 83% (20/24)
remote: Counting objects: 87% (21/24)
remote: Counting objects: 91% (22/24)
remote: Counting objects: 95% (23/24)
remote: Counting objects: 100% (24/24)
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 8% (1/12)
remote: Compressing objects: 16% (2/12)
remote: Compressing objects: 25% (3/12)
remote: Compressing objects: 33% (4/12)
remote: Compressing objects: 41% (5/12)
remote: Compressing objects: 50% (6/12)
remote: Compressing objects: 58% (7/12)
remote: Compressing objects: 66% (8/12)
remote: Compressing objects: 75% (9/12)
remote: Compressing objects: 83% (10/12)
remote: Compressing objects: 91% (11/12)
remote: Compressing objects: 100% (12/12)
remote: Compressing objects: 100% (12/12), done.
remote: Total 27 (delta 12), reused 12 (delta 12), pack-reused 3 (from 1)
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to 'ba687d9481c04fd160795ff8d8568f5c9f877128'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at ba687d9481c gh-121735: Fix module-adjacent references in zip files (#123037)
Switched to and reset branch 'main'
configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
make: *** [Makefile:2305: buildbottest] Terminated |
Sorry, something went wrong.
…ythonGH-123037) * pythongh-116608: Apply style and compatibility changes from importlib_metadata. * pythongh-121735: Ensure module-adjacent resources are loadable from a zipfile. * pythongh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused. (cherry picked from commit ba687d9) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
|
In jaraco/cpython@330cfcdae71, I've started work on a backport, but it's really broken. I got stuck when |
Sorry, something went wrong.
…ythonGH-123037) * pythongh-116608: Apply style and compatibility changes from importlib_metadata. * pythongh-121735: Ensure module-adjacent resources are loadable from a zipfile. * pythongh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused. (cherry picked from commit ba687d9) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Sorry, something went wrong.
) (#123986) * gh-121735: Fix module-adjacent references in zip files (GH-123037) * gh-116608: Apply style and compatibility changes from importlib_metadata. * gh-121735: Ensure module-adjacent resources are loadable from a zipfile. * gh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused. (cherry picked from commit ba687d9) * gh-123994: Generate utf-16 file using little endian and BOM. (#123995) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Merge after #123028.