@@ -30,7 +30,7 @@ char **main_argv;
30
30
/* Use path starting with "./" avoids a search along the PATH */
31
31
#define PROGRAM_NAME L"./_testembed"
32
32
33
- #define INIT_LOOPS 16
33
+ #define INIT_LOOPS 4
34
34
35
35
// Ignore Py_DEPRECATED() compiler warnings: deprecated functions are
36
36
// tested on purpose here.
@@ -45,10 +45,39 @@ static void error(const char *msg)
45
45
}
46
46
47
47
48
+ static void config_set_string (PyConfig * config , wchar_t * * config_str , const wchar_t * str )
49
+ {
50
+ PyStatus status = PyConfig_SetString (config , config_str , str );
51
+ if (PyStatus_Exception (status )) {
52
+ PyConfig_Clear (config );
53
+ Py_ExitStatusException (status );
54
+ }
55
+ }
56
+
57
+
58
+ static void config_set_program_name (PyConfig * config )
59
+ {
60
+ const wchar_t * program_name = PROGRAM_NAME ;
61
+ config_set_string (config , & config -> program_name , program_name );
62
+ }
63
+
64
+
65
+ static void init_from_config_clear (PyConfig * config )
66
+ {
67
+ PyStatus status = Py_InitializeFromConfig (config );
68
+ PyConfig_Clear (config );
69
+ if (PyStatus_Exception (status )) {
70
+ Py_ExitStatusException (status );
71
+ }
72
+ }
73
+
74
+
48
75
static void _testembed_Py_Initialize (void )
49
76
{
50
- Py_SetProgramName (PROGRAM_NAME );
51
- Py_Initialize ();
77
+ PyConfig config ;
78
+ _PyConfig_InitCompatConfig (& config );
79
+ config_set_program_name (& config );
80
+ init_from_config_clear (& config );
52
81
}
53
82
54
83
@@ -391,16 +420,6 @@ static int test_init_initialize_config(void)
391
420
}
392
421
393
422
394
- static void config_set_string (PyConfig * config , wchar_t * * config_str , const wchar_t * str )
395
- {
396
- PyStatus status = PyConfig_SetString (config , config_str , str );
397
- if (PyStatus_Exception (status )) {
398
- PyConfig_Clear (config );
399
- Py_ExitStatusException (status );
400
- }
401
- }
402
-
403
-
404
423
static void config_set_argv (PyConfig * config , Py_ssize_t argc , wchar_t * const * argv )
405
424
{
406
425
PyStatus status = PyConfig_SetArgv (config , argc , argv );
@@ -423,23 +442,6 @@ config_set_wide_string_list(PyConfig *config, PyWideStringList *list,
423
442
}
424
443
425
444
426
- static void config_set_program_name (PyConfig * config )
427
- {
428
- const wchar_t * program_name = PROGRAM_NAME ;
429
- config_set_string (config , & config -> program_name , program_name );
430
- }
431
-
432
-
433
- static void init_from_config_clear (PyConfig * config )
434
- {
435
- PyStatus status = Py_InitializeFromConfig (config );
436
- PyConfig_Clear (config );
437
- if (PyStatus_Exception (status )) {
438
- Py_ExitStatusException (status );
439
- }
440
- }
441
-
442
-
443
445
static int check_init_compat_config (int preinit )
444
446
{
445
447
PyStatus status ;
0 commit comments