GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — gh-96512: Modernize int_max_str_digits protection in 3.12 by gpshead · Pull Request #96568 · python/cpython Conversation
|
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
What's the rationale for that? It makes this specific option special and requires special code in Python/initconfig.c and other places. I would prefer to use an int for all integer options. If you want to put min or max values, you can add debug checks in config_check_consistency() and checks in _PyConfig_Read(). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR is hard to review, it does many things at once:
You might split it into separated PR, like move the addition of audit events to a new PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
With the adding of PyConfig.int_max_str_digits, IMO PyInterpreterState.int_max_str_digits becomes redundant and can introduce inconsistencies. I suggest removing it.
In PyInterpreterState, PyInterpreterState.config is a directly structure, not a pointer. At the machine code level, reading PyInterpreterState.config.int_max_str_digits is efficient: the offset in the memory is constant.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
nitpick: in the commit message, you should mention that the change also removes _Py_global_config_int_max_str_digits. I suggest to start with a PR with replaces _Py_global_config_int_max_str_digits + PyInterpreterState.int_max_str_digits with PyConfig.int_max_str_digits. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks! Yep this is entirely reasonable to split up into separate PRs. The audit hook can go away, it was just an idea. I've personally never used those. I used individual commits for each list item to make wrangling this into smaller PRs after concept review easy, will do. Using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Let's just leave it as is. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
No, not safely, unless we know for sure that I'm more than happy to make |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
In PyConfig, we can reject values which don't fit in an uint32_t, to make sure that the cast is safe. No? What's the issue on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Assuming you mean
The usual one whenever you're converting between two signed integer types that aren't known to have the same width - potential for undefined behaviour from overflow. There's no guarantee from the C standard that I've put significant effort over the years into making sure that Object/longobject.c is highly portable and depends on very little beyond what's guaranteed by the C standards; I care very much about keeping that the case. But really, this isn't worth the discussion at this point; I really wasn't anticipating that my request to use Py_ssize_t instead of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Will do. Crafting the change was an informative exercise regardless. I'm a fan of always using explicitly sized types, so any attempt to do so in a codebase that didn't start out that way reveals how ready it is or isn't. I'll dive back in on this code next week sometime, but questions in the back of my mind before I do that you may know already: PyConfig vs PyInterpreterState vs subinterpreters? Right now I believe each subinterpreter gets its own limit. We need a test for that. I wouldn't want a Similarly, PyConfig... is that intended to be mutable beyond process startup? I thought might be meant to represent the environment and flag values at start, not not necessarily settings that were changed via APIs afterwards. thoughts? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark:
I don't think that only this specific change is a good motivation to require 32-bit int to build Python. So far, we did our best to support all architectures. We accepted a change to support m68k (the code was generalized recently: commit dec0757). Hum. I checked and it seems like m68k uses 32-bit int, at least on Linux ;-) Well, it seems like on Linux, int is always 32-bit. I heard (Wikipedia) about ILP64 and SILP64 which use 64-bit int, but it seems to be outdated:
All modern operating systems use 32-bit int. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark:
My concern is more about the maintenance burden of Python/initconfig.c. Adding a new variable already requires a lot of code, as you can see in this PR. I would prefer to keep the code as simple as possible, by using only a few types: I'm fine with using Gregory:
So maybe all PyConfig integer members should become int32_t? I don't know. The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Each interpreter has its own config in Oh, there was a test API to set _isolated_interpreter=1, but it seems like it's gone. Or I misremember. Example modifying the sub-interpreter config with _testinternalcapi.set_config(): import _testcapi import _testinternalcapi code = """ import _testinternalcapi config = _testinternalcapi.get_config() config['bytes_warning'] = 2 _testinternalcapi.set_config(config) print("bytes warnings of the sub-interpreter?", _testinternalcapi.get_config()['bytes_warning']) """ _testcapi.run_in_subinterp(code) print("bytes warnings of main interpreter?", _testinternalcapi.get_config()['bytes_warning']) Output: Modifying the sub-interpreter config doesn't modify the main interpreter config ;-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
the pair of PRs mentioned above replace this with & address the feedback. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.