@@ -516,6 +516,7 @@ _PyCoreConfig_Clear(_PyCoreConfig *config)
516516 CLEAR (config -> run_command );
517517 CLEAR (config -> run_module );
518518 CLEAR (config -> run_filename );
519+ CLEAR (config -> check_hash_pycs_mode );
519520#undef CLEAR
520521}
521522
@@ -686,7 +687,7 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
686687 COPY_WSTR_ATTR (run_command );
687688 COPY_WSTR_ATTR (run_module );
688689 COPY_WSTR_ATTR (run_filename );
689- COPY_ATTR ( _check_hash_pycs_mode );
690+ COPY_WSTR_ATTR ( check_hash_pycs_mode );
690691 COPY_ATTR (_frozen );
691692 COPY_ATTR (_init_main );
692693
@@ -792,7 +793,7 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
792793 SET_ITEM_WSTR (run_module );
793794 SET_ITEM_WSTR (run_filename );
794795 SET_ITEM_INT (_install_importlib );
795- SET_ITEM_STR ( _check_hash_pycs_mode );
796+ SET_ITEM_WSTR ( check_hash_pycs_mode );
796797 SET_ITEM_INT (_frozen );
797798 SET_ITEM_INT (_init_main );
798799
@@ -1711,6 +1712,7 @@ static _PyInitError
17111712config_parse_cmdline (_PyCoreConfig * config , _PyPreCmdline * precmdline ,
17121713 _PyWstrList * warnoptions )
17131714{
1715+ _PyInitError err ;
17141716 const _PyWstrList * argv = & precmdline -> argv ;
17151717 int print_version = 0 ;
17161718
@@ -1757,12 +1759,15 @@ config_parse_cmdline(_PyCoreConfig *config, _PyPreCmdline *precmdline,
17571759 case 0 :
17581760 // Handle long option.
17591761 assert (longindex == 0 ); // Only one long option now.
1760- if (!wcscmp (_PyOS_optarg , L"always" )) {
1761- config -> _check_hash_pycs_mode = "always" ;
1762- } else if (!wcscmp (_PyOS_optarg , L"never" )) {
1763- config -> _check_hash_pycs_mode = "never" ;
1764- } else if (!wcscmp (_PyOS_optarg , L"default" )) {
1765- config -> _check_hash_pycs_mode = "default" ;
1762+ if (wcscmp (_PyOS_optarg , L"always" ) == 0
1763+ || wcscmp (_PyOS_optarg , L"never" ) == 0
1764+ || wcscmp (_PyOS_optarg , L"default" ) == 0 )
1765+ {
1766+ err = _PyCoreConfig_SetWideString (& config -> check_hash_pycs_mode ,
1767+ _PyOS_optarg );
1768+ if (_Py_INIT_FAILED (err )) {
1769+ return err ;
1770+ }
17661771 } else {
17671772 fprintf (stderr , "--check-hash-based-pycs must be one of "
17681773 "'default', 'always', or 'never'\n" );
@@ -2131,6 +2136,13 @@ config_read_cmdline(_PyCoreConfig *config, _PyPreCmdline *precmdline)
21312136 goto done ;
21322137 }
21332138
2139+ if (config -> check_hash_pycs_mode == NULL ) {
2140+ err = _PyCoreConfig_SetWideString (& config -> check_hash_pycs_mode , L"default" );
2141+ if (_Py_INIT_FAILED (err )) {
2142+ goto done ;
2143+ }
2144+ }
2145+
21342146 err = _Py_INIT_OK ();
21352147
21362148done :
@@ -2254,7 +2266,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
22542266#ifdef MS_WINDOWS
22552267 assert (config -> legacy_windows_stdio >= 0 );
22562268#endif
2257- assert (config -> _check_hash_pycs_mode != NULL );
2269+ assert (config -> check_hash_pycs_mode != NULL );
22582270 assert (config -> _install_importlib >= 0 );
22592271 assert (config -> _frozen >= 0 );
22602272
0 commit comments