@@ -110,6 +110,7 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
110
110
SPEC (base_executable , WSTR_OPT , PUBLIC , SYS_ATTR ("_base_executable" )),
111
111
SPEC (base_prefix , WSTR_OPT , PUBLIC , SYS_ATTR ("base_prefix" )),
112
112
SPEC (bytes_warning , UINT , PUBLIC , SYS_FLAG (9 )),
113
+ SPEC (cpu_count , INT , PUBLIC , NO_SYS ),
113
114
SPEC (exec_prefix , WSTR_OPT , PUBLIC , SYS_ATTR ("exec_prefix" )),
114
115
SPEC (executable , WSTR_OPT , PUBLIC , SYS_ATTR ("executable" )),
115
116
SPEC (inspect , BOOL , PUBLIC , SYS_FLAG (1 )),
@@ -138,7 +139,6 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
138
139
SPEC (check_hash_pycs_mode , WSTR , READ_ONLY , NO_SYS ),
139
140
SPEC (code_debug_ranges , BOOL , READ_ONLY , NO_SYS ),
140
141
SPEC (configure_c_stdio , BOOL , READ_ONLY , NO_SYS ),
141
- SPEC (cpu_count , INT , READ_ONLY , NO_SYS ),
142
142
SPEC (dev_mode , BOOL , READ_ONLY , NO_SYS ), // sys.flags.dev_mode
143
143
SPEC (dump_refs , BOOL , READ_ONLY , NO_SYS ),
144
144
SPEC (dump_refs_file , WSTR_OPT , READ_ONLY , NO_SYS ),
@@ -4524,6 +4524,18 @@ config_set_sys_flag(const PyConfigSpec *spec, int int_value)
4524
4524
}
4525
4525
4526
4526
4527
+ // Set PyConfig.ATTR integer member
4528
+ static int
4529
+ config_set_int_attr (const PyConfigSpec * spec , int value )
4530
+ {
4531
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
4532
+ PyConfig * config = & interp -> config ;
4533
+ int * member = config_get_spec_member (config , spec );
4534
+ * member = value ;
4535
+ return 0 ;
4536
+ }
4537
+
4538
+
4527
4539
int
4528
4540
PyConfig_Set (const char * name , PyObject * value )
4529
4541
{
@@ -4632,17 +4644,21 @@ PyConfig_Set(const char *name, PyObject *value)
4632
4644
Py_UNREACHABLE ();
4633
4645
}
4634
4646
4635
-
4636
4647
if (spec -> sys .attr != NULL ) {
4637
4648
// Set the sys attribute, but don't set PyInterpreterState.config
4638
4649
// to keep the code simple.
4639
4650
return PySys_SetObject (spec -> sys .attr , value );
4640
4651
}
4641
- else if (spec -> sys .flag_index >= 0 && has_int_value ) {
4642
- return config_set_sys_flag (spec , int_value );
4643
- }
4644
- else if (strcmp (spec -> name , "int_max_str_digits" ) == 0 && has_int_value ) {
4645
- return _PySys_SetIntMaxStrDigits (int_value );
4652
+ else if (has_int_value ) {
4653
+ if (spec -> sys .flag_index >= 0 ) {
4654
+ return config_set_sys_flag (spec , int_value );
4655
+ }
4656
+ else if (strcmp (spec -> name , "int_max_str_digits" ) == 0 ) {
4657
+ return _PySys_SetIntMaxStrDigits (int_value );
4658
+ }
4659
+ else {
4660
+ return config_set_int_attr (spec , int_value );
4661
+ }
4646
4662
}
4647
4663
4648
4664
cannot_set :
0 commit comments