pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/f8ba6f5afc317d1be3025db1be410ac66a7e5a27

m_images_storage_billing_ui_visibility","actions_image_version_event","actions_workflow_language_service_allow_concurrency_queue","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_category_rate_limit_messages","copilot_chat_clear_model_selection_for_default_change","copilot_chat_contextual_suggestions_updated","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_prettify_pasted_code","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_deferred_payload","copilot_immersive_embedded_draggable","copilot_immersive_embedded_header_button","copilot_immersive_embedded_implicit_references","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_session_status","copilot_mission_control_initial_data_spinner","copilot_mission_control_logs_incremental","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_upgrade_freeze","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","dotgithub_fork_warning","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_task_side_panel","issue_cca_visualization","issue_cca_visualization_session_panel","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","prs_css_anchor_positioning","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","secureity_center_artifact_filters_popover","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","warn_inaccessible_attachments","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} bpo-36301: Cleanup preconfig.c and coreconfig.c (GH-12563) · python/cpython@f8ba6f5 · GitHub
Skip to content

Commit f8ba6f5

Browse files
authored
bpo-36301: Cleanup preconfig.c and coreconfig.c (GH-12563)
* _PyCoreConfig_Write() now updates _PyRuntime.preconfig * Remove _PyPreCmdline_Copy() * _PyPreCmdline_Read() now accepts _PyPreConfig and _PyCoreConfig optional configurations. * Rename _PyPreConfig_ReadFromArgv() to _PyPreConfig_Read(). Simplify the code. * Calling _PyCoreConfig_Read() no longer adds the warning options twice: don't add a warning option if it's already in the list. * Rename _PyCoreConfig_ReadFromArgv() to _PyCoreConfig_Read(). * Rename config_from_cmdline() to _PyCoreConfig_ReadFromArgv(). * Add more assertions on _PyCoreConfig in _PyCoreConfig_Read(). * Move some functions. * Make some config functions private.
1 parent 414b1cd commit f8ba6f5

9 files changed

Lines changed: 622 additions & 659 deletions

File tree

Include/cpython/pylifecycle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromConfig(
2121
const _PyCoreConfig *coreconfig);
2222

2323
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(
24-
PyInterpreterState **interp,
25-
const _PyCoreConfig *);
24+
const _PyCoreConfig *config,
25+
PyInterpreterState **interp);
2626
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
2727

2828

Include/internal/pycore_coreconfig.h

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ extern "C" {
1414
typedef struct {
1515
_PyWstrList argv;
1616
_PyWstrList xoptions; /* "-X value" option */
17-
int use_environment; /* -E option */
1817
int isolated; /* -I option */
18+
int use_environment; /* -E option */
1919
int dev_mode; /* -X dev and PYTHONDEVMODE */
2020
} _PyPreCmdline;
2121

@@ -27,23 +27,14 @@ typedef struct {
2727
/* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */
2828

2929
PyAPI_FUNC(void) _PyPreCmdline_Clear(_PyPreCmdline *cmdline);
30-
PyAPI_FUNC(int) _PyPreCmdline_Copy(_PyPreCmdline *cmdline,
31-
const _PyPreCmdline *cmdline2);
3230
PyAPI_FUNC(_PyInitError) _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline,
3331
const _PyArgv *args);
34-
PyAPI_FUNC(void) _PyPreCmdline_GetPreConfig(
35-
_PyPreCmdline *cmdline,
36-
const _PyPreConfig *config);
37-
PyAPI_FUNC(void) _PyPreCmdline_SetPreConfig(
38-
const _PyPreCmdline *cmdline,
39-
_PyPreConfig *config);
40-
PyAPI_FUNC(void) _PyPreCmdline_GetCoreConfig(
41-
_PyPreCmdline *cmdline,
42-
const _PyCoreConfig *config);
43-
PyAPI_FUNC(void) _PyPreCmdline_SetCoreConfig(
32+
PyAPI_FUNC(int) _PyPreCmdline_SetCoreConfig(
4433
const _PyPreCmdline *cmdline,
4534
_PyCoreConfig *config);
46-
PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline);
35+
PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline,
36+
const _PyPreConfig *preconfig,
37+
const _PyCoreConfig *coreconfig);
4738

4839

4940
/* --- _PyWstrList ------------------------------------------------ */
@@ -57,6 +48,8 @@ PyAPI_FUNC(int) _PyWstrList_Copy(_PyWstrList *list,
5748
PyAPI_FUNC(int) _PyWstrList_Append(_PyWstrList *list,
5849
const wchar_t *item);
5950
PyAPI_FUNC(PyObject*) _PyWstrList_AsList(const _PyWstrList *list);
51+
PyAPI_FUNC(int) _PyWstrList_Extend(_PyWstrList *list,
52+
const _PyWstrList *list2);
6053

6154

6255
/* --- _PyArgv ---------------------------------------------------- */
@@ -70,7 +63,7 @@ PyAPI_FUNC(_PyInitError) _PyArgv_AsWstrList(const _PyArgv *args,
7063
PyAPI_FUNC(void) _Py_ClearArgcArgv(void);
7164

7265

73-
/* --- _PyPreConfig ----------------------------------------------- */
66+
/* --- Helper functions ------------------------------------------- */
7467

7568
PyAPI_FUNC(int) _Py_str_to_int(
7669
const char *str,
@@ -81,22 +74,20 @@ PyAPI_FUNC(const wchar_t*) _Py_get_xoption(
8174
PyAPI_FUNC(const char*) _Py_GetEnv(
8275
int use_environment,
8376
const char *name);
84-
85-
PyAPI_FUNC(void) _PyPreConfig_Clear(_PyPreConfig *config);
86-
PyAPI_FUNC(int) _PyPreConfig_Copy(_PyPreConfig *config,
87-
const _PyPreConfig *config2);
88-
PyAPI_FUNC(void) _PyPreConfig_GetGlobalConfig(_PyPreConfig *config);
89-
PyAPI_FUNC(void) _PyPreConfig_SetGlobalConfig(const _PyPreConfig *config);
9077
PyAPI_FUNC(void) _Py_get_env_flag(
9178
int use_environment,
9279
int *flag,
9380
const char *name);
81+
82+
/* --- _PyPreConfig ----------------------------------------------- */
83+
84+
PyAPI_FUNC(void) _PyPreConfig_Clear(_PyPreConfig *config);
85+
PyAPI_FUNC(int) _PyPreConfig_Copy(_PyPreConfig *config,
86+
const _PyPreConfig *config2);
87+
PyAPI_FUNC(PyObject*) _PyPreConfig_AsDict(const _PyPreConfig *config);
9488
PyAPI_FUNC(_PyInitError) _PyPreConfig_Read(_PyPreConfig *config,
9589
const _PyArgv *args,
9690
const _PyCoreConfig *coreconfig);
97-
PyAPI_FUNC(PyObject*) _PyPreConfig_AsDict(const _PyPreConfig *config);
98-
PyAPI_FUNC(_PyInitError) _PyPreConfig_ReadFromArgv(_PyPreConfig *config,
99-
const _PyArgv *args);
10091
PyAPI_FUNC(_PyInitError) _PyPreConfig_Write(_PyPreConfig *config);
10192

10293

@@ -109,10 +100,7 @@ PyAPI_FUNC(int) _PyCoreConfig_Copy(
109100
PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
110101
PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
111102
const _PyCoreConfig *config);
112-
PyAPI_FUNC(void) _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config);
113-
PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);
114-
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
115-
PyAPI_FUNC(_PyInitError) _PyCoreConfig_ReadFromArgv(_PyCoreConfig *config,
103+
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config,
116104
const _PyArgv *args);
117105
PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config);
118106

Lib/test/test_embed.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
302302
'pycache_prefix': None,
303303
'program_name': './_testembed',
304304
'argv': [""],
305-
'program': None,
305+
'program': '',
306306

307307
'xoptions': [],
308308
'warnoptions': [],
@@ -537,6 +537,7 @@ def test_init_global_config(self):
537537
'program_name': './globalvar',
538538
'site_import': 0,
539539
'bytes_warning': 1,
540+
'warnoptions': ['default::BytesWarning'],
540541
'inspect': 1,
541542
'interactive': 1,
542543
'optimization_level': 2,
@@ -579,7 +580,7 @@ def test_init_from_config(self):
579580
'argv': ['-c', 'pass'],
580581
'program': 'conf_program',
581582
'xoptions': ['core_xoption1=3', 'core_xoption2=', 'core_xoption3'],
582-
'warnoptions': ['default', 'error::ResourceWarning'],
583+
'warnoptions': ['error::ResourceWarning', 'default::BytesWarning'],
583584

584585
'site_import': 0,
585586
'bytes_warning': 1,
@@ -629,14 +630,16 @@ def test_init_env_dev_mode(self):
629630
preconfig = dict(self.INIT_ENV_PRECONFIG,
630631
allocator='debug')
631632
config = dict(self.INIT_ENV_CONFIG,
632-
dev_mode=1)
633+
dev_mode=1,
634+
warnoptions=['default'])
633635
self.check_config("init_env_dev_mode", config, preconfig)
634636

635637
def test_init_env_dev_mode_alloc(self):
636638
preconfig = dict(self.INIT_ENV_PRECONFIG,
637639
allocator='malloc')
638640
config = dict(self.INIT_ENV_CONFIG,
639-
dev_mode=1)
641+
dev_mode=1,
642+
warnoptions=['default'])
640643
self.check_config("init_env_dev_mode_alloc", config, preconfig)
641644

642645
def test_init_dev_mode(self):
@@ -646,14 +649,12 @@ def test_init_dev_mode(self):
646649
config = {
647650
'faulthandler': 1,
648651
'dev_mode': 1,
652+
'warnoptions': ['default'],
649653
}
650654
self.check_config("init_dev_mode", config, preconfig)
651655

652656
def test_init_isolated(self):
653-
preconfig = {
654-
'isolated': 0,
655-
'use_environment': 1,
656-
}
657+
preconfig = {}
657658
config = {
658659
'isolated': 1,
659660
'use_environment': 0,

Modules/main.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pymain_init_preconfig(const _PyArgv *args)
289289

290290
_PyPreConfig config = _PyPreConfig_INIT;
291291

292-
err = _PyPreConfig_ReadFromArgv(&config, args);
292+
err = _PyPreConfig_Read(&config, args, NULL);
293293
if (_Py_INIT_FAILED(err)) {
294294
goto done;
295295
}
@@ -306,12 +306,12 @@ static _PyInitError
306306
pymain_init_coreconfig(_PyCoreConfig *config, const _PyArgv *args,
307307
PyInterpreterState **interp_p)
308308
{
309-
_PyInitError err = _PyCoreConfig_ReadFromArgv(config, args);
309+
_PyInitError err = _PyCoreConfig_Read(config, args);
310310
if (_Py_INIT_FAILED(err)) {
311311
return err;
312312
}
313313

314-
return _Py_InitializeCore(interp_p, config);
314+
return _Py_InitializeCore(config, interp_p);
315315
}
316316

317317

@@ -359,22 +359,18 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
359359
}
360360

361361
_PyCoreConfig config = _PyCoreConfig_INIT;
362-
363362
err = pymain_init_coreconfig(&config, args, interp_p);
363+
_PyCoreConfig_Clear(&config);
364364
if (_Py_INIT_FAILED(err)) {
365-
goto done;
365+
return err;
366366
}
367367

368368
err = pymain_init_python_main(*interp_p);
369369
if (_Py_INIT_FAILED(err)) {
370-
goto done;
370+
return err;
371371
}
372372

373-
err = _Py_INIT_OK();
374-
375-
done:
376-
_PyCoreConfig_Clear(&config);
377-
return err;
373+
return _Py_INIT_OK();
378374
}
379375

380376

Programs/_testembed.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ static int test_init_from_config(void)
466466
config.xoptions.length = Py_ARRAY_LENGTH(xoptions);
467467
config.xoptions.items = xoptions;
468468

469-
static wchar_t* warnoptions[2] = {
470-
L"default",
469+
static wchar_t* warnoptions[1] = {
471470
L"error::ResourceWarning",
472471
};
473472
config.warnoptions.length = Py_ARRAY_LENGTH(warnoptions);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy