@@ -110,6 +110,7 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
110110 SPEC (base_executable , WSTR_OPT , PUBLIC , SYS_ATTR ("_base_executable" )),
111111 SPEC (base_prefix , WSTR_OPT , PUBLIC , SYS_ATTR ("base_prefix" )),
112112 SPEC (bytes_warning , UINT , PUBLIC , SYS_FLAG (9 )),
113+ SPEC (cpu_count , INT , PUBLIC , NO_SYS ),
113114 SPEC (exec_prefix , WSTR_OPT , PUBLIC , SYS_ATTR ("exec_prefix" )),
114115 SPEC (executable , WSTR_OPT , PUBLIC , SYS_ATTR ("executable" )),
115116 SPEC (inspect , BOOL , PUBLIC , SYS_FLAG (1 )),
@@ -138,7 +139,6 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
138139 SPEC (check_hash_pycs_mode , WSTR , READ_ONLY , NO_SYS ),
139140 SPEC (code_debug_ranges , BOOL , READ_ONLY , NO_SYS ),
140141 SPEC (configure_c_stdio , BOOL , READ_ONLY , NO_SYS ),
141- SPEC (cpu_count , INT , READ_ONLY , NO_SYS ),
142142 SPEC (dev_mode , BOOL , READ_ONLY , NO_SYS ), // sys.flags.dev_mode
143143 SPEC (dump_refs , BOOL , READ_ONLY , NO_SYS ),
144144 SPEC (dump_refs_file , WSTR_OPT , READ_ONLY , NO_SYS ),
@@ -4524,6 +4524,18 @@ config_set_sys_flag(const PyConfigSpec *spec, int int_value)
45244524}
45254525
45264526
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+
45274539int
45284540PyConfig_Set (const char * name , PyObject * value )
45294541{
@@ -4632,17 +4644,21 @@ PyConfig_Set(const char *name, PyObject *value)
46324644 Py_UNREACHABLE ();
46334645 }
46344646
4635-
46364647 if (spec -> sys .attr != NULL ) {
46374648 // Set the sys attribute, but don't set PyInterpreterState.config
46384649 // to keep the code simple.
46394650 return PySys_SetObject (spec -> sys .attr , value );
46404651 }
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+ }
46464662 }
46474663
46484664cannot_set :
0 commit comments