Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-96512: Move int_max_str_digits setting to PyConfig#96944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cf20758
gh-96512: Move int_max_str_digits setting to PyConfig
gpshead 86c4b6e
Add a test_capi test to verify unique configs.
gpshead 26dfda5
NEWS entry.
gpshead 34feabc
Merge branch 'main' into cleanup/int-dos-use-pyconfig
gpshead 21a21ed
Split and move the subinterpreter isolation tests
gpshead 8b4561d
Address review comments.
gpshead 7247e78
Don't expose -1 in sys.flags.
gpshead d8f1d8e
Merge branch 'main' into cleanup/int-dos-use-pyconfig
gpshead 1a5935d
clarify the purpose of the test_capi test via comment
gpshead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -999,6 +999,39 @@ async def foo(arg): return await arg # Py 3.5 | ||
| self.assertEqual(ret, 0) | ||
| self.assertEqual(pickle.load(f), {'a': '123x', 'b': '123'}) | ||
| def test_py_config_isoloated_per_interpreter(self): | ||
| # A config change in one interpreter must not leak to out to others. | ||
| # | ||
| # This test could verify ANY config value, it just happens to have been | ||
| # written around the time of int_max_str_digits. Refactoring is okay. | ||
| code = """if 1: | ||
| import sys, _testinternalcapi | ||
| # Any config value would do, this happens to be the one being | ||
| # double checked at the time this test was written. | ||
| config = _testinternalcapi.get_config() | ||
| config['int_max_str_digits'] = 55555 | ||
| _testinternalcapi.set_config(config) | ||
| sub_value = _testinternalcapi.get_config()['int_max_str_digits'] | ||
| assert sub_value == 55555, sub_value | ||
| """ | ||
| before_config = _testinternalcapi.get_config() | ||
| assert before_config['int_max_str_digits'] != 55555 | ||
gpshead marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| self.assertEqual(support.run_in_subinterp(code), 0, | ||
| 'subinterp code failure, check stderr.') | ||
| after_config = _testinternalcapi.get_config() | ||
| self.assertIsNot( | ||
| before_config, after_config, | ||
| "Expected get_config() to return a new dict on each call") | ||
| self.assertEqual(before_config, after_config, | ||
| "CAUTION: Tests executed after this may be " | ||
| "running under an altered config.") | ||
| # try:...finally: calling set_config(before_config) not done | ||
| # as that results in sys.argv, sys.path, and sys.warnoptions | ||
| # "being modified by test_capi" per test.regrtest. So if this | ||
| # test fails, assume that the environment in this process may | ||
| # be altered and suspect. | ||
| def test_mutate_exception(self): | ||
| """ | ||
| Exceptions saved in global module state get shared between | ||
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
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
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
2 changes: 2 additions & 0 deletions
2 Misc/NEWS.d/next/C API/2022-09-20-01-04-57.gh-issue-96512.msZTjF.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Configuration for the :ref:`integer string conversion length limitation | ||
| <int_max_str_digits>` now lives in the PyConfig C API struct. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -683,6 +683,9 @@ static int test_init_from_config(void) | ||
| config._isolated_interpreter = 1; | ||
| putenv("PYTHONINTMAXSTRDIGITS=6666"); | ||
gpshead marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| config.int_max_str_digits = 31337; | ||
| init_from_config_clear(&config); | ||
| dump_config(); | ||
| @@ -748,6 +751,7 @@ static void set_most_env_vars(void) | ||
| putenv("PYTHONIOENCODING=iso8859-1:replace"); | ||
| putenv("PYTHONPLATLIBDIR=env_platlibdir"); | ||
| putenv("PYTHONSAFEPATH=1"); | ||
| putenv("PYTHONINTMAXSTRDIGITS=4567"); | ||
| } | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.