@@ -439,6 +439,8 @@ Py_GetArgcArgv(int *argc, wchar_t ***argv)
439
439
void
440
440
_PyCoreConfig_Clear (_PyCoreConfig * config )
441
441
{
442
+ _PyPreConfig_Clear (& config -> preconfig );
443
+
442
444
#define CLEAR (ATTR ) \
443
445
do { \
444
446
PyMem_RawFree(ATTR); \
@@ -488,6 +490,10 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
488
490
{
489
491
_PyCoreConfig_Clear (config );
490
492
493
+ if (_PyPreConfig_Copy (& config -> preconfig , & config2 -> preconfig ) < 0 ) {
494
+ return -1 ;
495
+ }
496
+
491
497
#define COPY_ATTR (ATTR ) config->ATTR = config2->ATTR
492
498
#define COPY_STR_ATTR (ATTR ) \
493
499
do { \
@@ -519,7 +525,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
519
525
} while (0)
520
526
521
527
COPY_ATTR (install_signal_handlers );
522
- COPY_ATTR (use_environment );
523
528
COPY_ATTR (use_hash_seed );
524
529
COPY_ATTR (hash_seed );
525
530
COPY_ATTR (_install_importlib );
@@ -557,7 +562,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
557
562
#endif
558
563
COPY_WSTR_ATTR (base_exec_prefix );
559
564
560
- COPY_ATTR (isolated );
561
565
COPY_ATTR (site_import );
562
566
COPY_ATTR (bytes_warning );
563
567
COPY_ATTR (inspect );
@@ -595,9 +599,9 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
595
599
const char *
596
600
_PyCoreConfig_GetEnv (const _PyCoreConfig * config , const char * name )
597
601
{
598
- assert (config -> use_environment >= 0 );
602
+ assert (config -> preconfig . use_environment >= 0 );
599
603
600
- if (!config -> use_environment ) {
604
+ if (!config -> preconfig . use_environment ) {
601
605
return NULL ;
602
606
}
603
607
@@ -616,9 +620,9 @@ _PyCoreConfig_GetEnvDup(const _PyCoreConfig *config,
616
620
wchar_t * * dest ,
617
621
wchar_t * wname , char * name )
618
622
{
619
- assert (config -> use_environment >= 0 );
623
+ assert (config -> preconfig . use_environment >= 0 );
620
624
621
- if (!config -> use_environment ) {
625
+ if (!config -> preconfig . use_environment ) {
622
626
* dest = NULL ;
623
627
return 0 ;
624
628
}
@@ -662,6 +666,8 @@ _PyCoreConfig_GetEnvDup(const _PyCoreConfig *config,
662
666
void
663
667
_PyCoreConfig_GetGlobalConfig (_PyCoreConfig * config )
664
668
{
669
+ _PyPreConfig_GetGlobalConfig (& config -> preconfig );
670
+
665
671
#define COPY_FLAG (ATTR , VALUE ) \
666
672
if (config->ATTR == -1) { \
667
673
config->ATTR = VALUE; \
@@ -672,7 +678,6 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
672
678
}
673
679
674
680
COPY_FLAG (utf8_mode , Py_UTF8Mode );
675
- COPY_FLAG (isolated , Py_IsolatedFlag );
676
681
COPY_FLAG (bytes_warning , Py_BytesWarningFlag );
677
682
COPY_FLAG (inspect , Py_InspectFlag );
678
683
COPY_FLAG (interactive , Py_InteractiveFlag );
@@ -686,7 +691,6 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
686
691
#endif
687
692
COPY_FLAG (_frozen , Py_FrozenFlag );
688
693
689
- COPY_NOT_FLAG (use_environment , Py_IgnoreEnvironmentFlag );
690
694
COPY_NOT_FLAG (buffered_stdio , Py_UnbufferedStdioFlag );
691
695
COPY_NOT_FLAG (site_import , Py_NoSiteFlag );
692
696
COPY_NOT_FLAG (write_bytecode , Py_DontWriteBytecodeFlag );
@@ -701,6 +705,8 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
701
705
void
702
706
_PyCoreConfig_SetGlobalConfig (const _PyCoreConfig * config )
703
707
{
708
+ _PyPreConfig_SetGlobalConfig (& config -> preconfig );
709
+
704
710
#define COPY_FLAG (ATTR , VAR ) \
705
711
if (config->ATTR != -1) { \
706
712
VAR = config->ATTR; \
@@ -711,7 +717,6 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
711
717
}
712
718
713
719
COPY_FLAG (utf8_mode , Py_UTF8Mode );
714
- COPY_FLAG (isolated , Py_IsolatedFlag );
715
720
COPY_FLAG (bytes_warning , Py_BytesWarningFlag );
716
721
COPY_FLAG (inspect , Py_InspectFlag );
717
722
COPY_FLAG (interactive , Py_InteractiveFlag );
@@ -725,7 +730,6 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
725
730
#endif
726
731
COPY_FLAG (_frozen , Py_FrozenFlag );
727
732
728
- COPY_NOT_FLAG (use_environment , Py_IgnoreEnvironmentFlag );
729
733
COPY_NOT_FLAG (buffered_stdio , Py_UnbufferedStdioFlag );
730
734
COPY_NOT_FLAG (site_import , Py_NoSiteFlag );
731
735
COPY_NOT_FLAG (write_bytecode , Py_DontWriteBytecodeFlag );
@@ -1497,10 +1501,15 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
1497
1501
_PyInitError err ;
1498
1502
1499
1503
_PyCoreConfig_GetGlobalConfig (config );
1500
- assert (config -> use_environment >= 0 );
1501
1504
1502
- if (config -> isolated > 0 ) {
1503
- config -> use_environment = 0 ;
1505
+ err = _PyPreConfig_Read (& config -> preconfig );
1506
+ if (_Py_INIT_FAILED (err )) {
1507
+ return err ;
1508
+ }
1509
+
1510
+ assert (config -> preconfig .use_environment >= 0 );
1511
+
1512
+ if (config -> preconfig .isolated > 0 ) {
1504
1513
config -> user_site_directory = 0 ;
1505
1514
}
1506
1515
@@ -1510,7 +1519,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
1510
1519
}
1511
1520
#endif
1512
1521
1513
- if (config -> use_environment ) {
1522
+ if (config -> preconfig . use_environment ) {
1514
1523
err = config_read_env_vars (config );
1515
1524
if (_Py_INIT_FAILED (err )) {
1516
1525
return err ;
@@ -1611,7 +1620,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
1611
1620
}
1612
1621
1613
1622
assert (config -> coerce_c_locale >= 0 );
1614
- assert (config -> use_environment >= 0 );
1623
+ assert (config -> preconfig . use_environment >= 0 );
1615
1624
assert (config -> filesystem_encoding != NULL );
1616
1625
assert (config -> filesystem_errors != NULL );
1617
1626
assert (config -> stdio_encoding != NULL );
@@ -1679,18 +1688,23 @@ _PyCoreConfig_Write(const _PyCoreConfig *config)
1679
1688
PyObject *
1680
1689
_PyCoreConfig_AsDict (const _PyCoreConfig * config )
1681
1690
{
1682
- PyObject * dict , * obj ;
1691
+ PyObject * dict ;
1683
1692
1684
1693
dict = PyDict_New ();
1685
1694
if (dict == NULL ) {
1686
1695
return NULL ;
1687
1696
}
1688
1697
1698
+ if (_PyPreConfig_AsDict (& config -> preconfig , dict ) < 0 ) {
1699
+ Py_DECREF (dict );
1700
+ return NULL ;
1701
+ }
1702
+
1689
1703
#define SET_ITEM (KEY , EXPR ) \
1690
1704
do { \
1691
- obj = (EXPR); \
1705
+ PyObject * obj = (EXPR); \
1692
1706
if (obj == NULL) { \
1693
- return NULL ; \
1707
+ goto fail ; \
1694
1708
} \
1695
1709
int res = PyDict_SetItemString(dict, (KEY), obj); \
1696
1710
Py_DECREF(obj); \
@@ -1718,7 +1732,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
1718
1732
SET_ITEM(#OPTIONS, _Py_wstrlist_as_pylist(config->NOPTION, config->OPTIONS))
1719
1733
1720
1734
SET_ITEM_INT (install_signal_handlers );
1721
- SET_ITEM_INT (use_environment );
1722
1735
SET_ITEM_INT (use_hash_seed );
1723
1736
SET_ITEM_UINT (hash_seed );
1724
1737
SET_ITEM_STR (allocator );
@@ -1752,7 +1765,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
1752
1765
#ifdef MS_WINDOWS
1753
1766
SET_ITEM_WSTR (dll_path );
1754
1767
#endif
1755
- SET_ITEM_INT (isolated );
1756
1768
SET_ITEM_INT (site_import );
1757
1769
SET_ITEM_INT (bytes_warning );
1758
1770
SET_ITEM_INT (inspect );
@@ -1828,14 +1840,6 @@ cmdline_clear(_PyCmdline *cmdline)
1828
1840
}
1829
1841
1830
1842
1831
- static _PyInitError
1832
- cmdline_decode_argv (_PyCmdline * cmdline )
1833
- {
1834
- assert (cmdline -> argv == NULL );
1835
- return _PyArgv_Decode (cmdline -> args , & cmdline -> argv );
1836
- }
1837
-
1838
-
1839
1843
/* --- _PyCoreConfig command line parser -------------------------- */
1840
1844
1841
1845
/* Parse the command line arguments */
@@ -1912,7 +1916,7 @@ config_parse_cmdline(_PyCoreConfig *config, _PyCmdline *cmdline,
1912
1916
break ;
1913
1917
1914
1918
case 'I' :
1915
- config -> isolated ++ ;
1919
+ config -> preconfig . isolated ++ ;
1916
1920
break ;
1917
1921
1918
1922
/* case 'J': reserved for Jython */
@@ -1934,7 +1938,7 @@ config_parse_cmdline(_PyCoreConfig *config, _PyCmdline *cmdline,
1934
1938
break ;
1935
1939
1936
1940
case 'E' :
1937
- config -> use_environment = 0 ;
1941
+ config -> preconfig . use_environment = 0 ;
1938
1942
break ;
1939
1943
1940
1944
case 't' :
@@ -2272,7 +2276,7 @@ config_from_cmdline(_PyCoreConfig *config, _PyCmdline *cmdline)
2272
2276
return err ;
2273
2277
}
2274
2278
2275
- if (config -> use_environment ) {
2279
+ if (config -> preconfig . use_environment ) {
2276
2280
err = cmdline_init_env_warnoptions (cmdline , config );
2277
2281
if (_Py_INIT_FAILED (err )) {
2278
2282
return err ;
0 commit comments