- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.3k
 
bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config #31771
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
base: main
Are you sure you want to change the base?
Conversation
3f29756    to
    81eda9b      
    Compare
  
    | /* Allow the creation of threads. */ | ||
| unsigned int allow_threading:1; | ||
| /* Padding to ensure byte alignment. */ | ||
| unsigned int :5; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
structs must be at least byte aligned, so this isn't strictly necessary.
| PyInterpreterState *interp = _PyInterpreterState_GET(); | ||
| /* pymain_run_stdin() modify the config */ | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the cast?
| { | ||
| /* Update the stdio encoding to the normalized Python codec name. */ | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the cast?
| For example, replace "ANSI_X3.4-1968" (locale encoding) with "ascii" | ||
| (Python codec name). */ | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); | ||
| PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| { | ||
| PyInterpreterState *interp = _PyInterpreterState_GET(); | ||
| PyConfig *config = (PyConfig *)_PyInterpreterState_GetConfig(interp); | ||
| PyConfig *config = (PyConfig *)_PyInterpreterState_GetGlobalConfig(interp); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| void | ||
| _PyInterpreterConfig_Clear(_PyInterpreterConfig *config) | ||
| { | ||
| *config = (_PyInterpreterConfig){}; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs struct?
| } | ||
| 
               | 
          ||
| status = _PyConfig_Copy(&tstate->interp->config, &config); | ||
| status = _PyConfig_Copy(&tstate->interp->runtime->config, &config); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a very convoluted way to get a static object
| 
           
  | 
    
| 
           Yeah, there are a few things that I need to follow up on here.  | 
    
As part of this, we also move
PyConfig._isolated_interpreterto a new_PyInterpreterConfigstruct and split it up into more granular settings. We also change some of the private API names to explicitly indicate they relate to global config.https://bugs.python.org/issue46964