Uh oh!
There was an error while loading. Please reload this page.
[3.13] gh-128911: Add tests on the PyImport C API (#128915) - #128960
Merged
Conversation
vstinner
requested review from
a team, brettcannon, ericsnowcurrently, ncoghlan and warsaw
as code ownersJanuary 17, 2025 21:05
This was referenced Jan 17, 2025
vstinner
commented
Jan 17, 2025
MemberAuthor
@serhiy-storchaka: In Python 3.13, non-string names lead to crashes. I had to remove these tests: diff --git a/Lib/test/test_capi/test_import.py b/Lib/test/test_capi/test_import.py
index 94f96728d91..3abd1cd7470 100644
--- a/Lib/test/test_capi/test_import.py+++ b/Lib/test/test_capi/test_import.py@@ -70,8 +70,6 @@ def check_addmodule(self, add_module, accept_nonstr=False):
names = ['nonexistent']
if accept_nonstr:
names.append(b'\xff') # non-UTF-8
- # PyImport_AddModuleObject() accepts non-string names- names.append(tuple(['hashable non-string']))
for name in names:
with self.subTest(name=name):
self.assertNotIn(name, sys.modules)
@@ -311,9 +309,6 @@ def test_executecodemoduleobject(self):
code = compile('attr = 1', '<test>', 'exec')
self.assertRaises(TypeError, execute_code_func, [], code, NULL, NULL)
- nonstring = tuple(['hashable non-string'])- self.assertRaises(AttributeError, execute_code_func, nonstring, code, NULL, NULL)- sys.modules.pop(nonstring, None)
# CRASHES execute_code_func(NULL, code, NULL, NULL)
# CRASHES execute_code_func(name, NULL, NULL, NULL)
|
* Add Modules/_testlimitedcapi/import.c * Add Lib/test/test_capi/test_import.py * Remove _testcapi.check_pyimport_addmodule(): tests already covered by newly added tests. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit d95ba9f)
vstinnerforce-pushed
the
test_capi_import13
branch
from
January 17, 2025 21:19
a53147b to
4f21755CompareThanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @vstinner, I could not cleanly backport this to |
vstinner
commented
Jan 17, 2025
MemberAuthor
The change cannot be backported to 3.12: |
serhiy-storchaka added a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Jan 18, 2025
…nGH-128915) (pythonGH-128960) pythongh-128911: Add tests on the PyImport C API (pythonGH-128915) * Add Modules/_testlimitedcapi/import.c * Add Lib/test/test_capi/test_import.py * Remove _testcapi.check_pyimport_addmodule(): tests already covered by newly added tests. (cherry picked from commit 34ded1a) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit d95ba9f)
GH-128989 is a backport of this pull request to the 3.12 branch. |
vstinner added a commit
that referenced
this pull request
Jan 19, 2025
) (#128989) * Add Modules/_testlimitedcapi/import.c * Add Lib/test/test_capi/test_import.py * Remove _testcapi.check_pyimport_addmodule(): tests already covered by newly added tests. (cherry picked from commit 34ded1a) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit d95ba9f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co-authored-by: Serhiy Storchaka storchaka@gmail.com
(cherry picked from commit d95ba9f)