summaryrefslogtreecommitdiffstats
path: root/Include/pystate.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-07-24 11:55:48 (GMT)
committerGitHub <noreply@github.com>2018-07-24 11:55:48 (GMT)
commitd19d8d5279f156bc8f6736b5f16f069879b9519b (patch)
treedc3c2561371a0be4410172fe4270a37ab7c76ba6 /Include/pystate.h
parentac0b3c2f4d86fc056b833a4e6b9a380741244a63 (diff)
downloadcpython-d19d8d5279f156bc8f6736b5f16f069879b9519b.zip
cpython-d19d8d5279f156bc8f6736b5f16f069879b9519b.tar.gz
cpython-d19d8d5279f156bc8f6736b5f16f069879b9519b.tar.bz2
bpo-34170: Add _PyCoreConfig.isolated (GH-8417)
* _PyCoreConfig: add isolated and site_import attributes * Replace Py_IgnoreEnvironment with config->ignore_environment when reading the current configuration * _PyCoreConfig_Read() now sets ignore_environment, utf8_mode, isolated and site_import from Py_IgnoreEnvironment, Py_UTF8Mode, Py_IsolatedFlag and Py_NoSiteFlag * _Py_InitializeCore() now sets Py_xxx flags from the configuration * pymain_read_conf() now uses _PyCoreConfig_Copy() to save/restore the configuration. * Rename _disable_importlib of _PyCoreConfig to _install_importlib * _PyCoreConfig_SetGlobalConfig() now also set Py_HashRandomizationFlag * Replace !Py_NoSiteFlag with core_config->site_import
Diffstat (limited to 'Include/pystate.h')
-rw-r--r--Include/pystate.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/Include/pystate.h b/Include/pystate.h
index ac09dc3..609f9c6 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -28,7 +28,7 @@ typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
typedef struct {
int install_signal_handlers; /* Install signal handlers? -1 means unset */
- int ignore_environment; /* -E, Py_IgnoreEnvironmentFlag */
+ int ignore_environment; /* -E, Py_IgnoreEnvironmentFlag, -1 means unset */
int use_hash_seed; /* PYTHONHASHSEED=x */
unsigned long hash_seed;
const char *allocator; /* Memory allocator: _PyMem_SetupAllocators() */
@@ -75,18 +75,42 @@ typedef struct {
wchar_t *dll_path; /* Windows DLL path */
#endif
- /* Private fields */
- int _disable_importlib; /* Needed by freeze_importlib */
+ /* If greater than 0, enable isolated mode: sys.path contains
+ neither the script's directory nor the user's site-packages directory.
+
+ Set to 1 by the -I command line option. If set to -1 (default), inherit
+ Py_IsolatedFlag value. */
+ int isolated;
+
+ /* If equal to zero, disable the import of the module site and the
+ site-dependent manipulations of sys.path that it entails. Also disable
+ these manipulations if site is explicitly imported later (call
+ site.main() if you want them to be triggered).
+
+ Set to 0 by the -S command line option. If set to -1 (default), set to
+ the negative value of Py_NoSiteFlag. */
+ int site_import;
+
+ /* --- Private fields -------- */
+
+ /* Install importlib? If set to 0, importlib is not initialized at all.
+ Needed by freeze_importlib: see install_importlib argument of
+ _Py_InitializeEx_Private(). */
+ int _install_importlib;
} _PyCoreConfig;
#define _PyCoreConfig_INIT \
(_PyCoreConfig){ \
.install_signal_handlers = -1, \
+ .ignore_environment = -1, \
.use_hash_seed = -1, \
.coerce_c_locale = -1, \
.utf8_mode = -1, \
.argc = -1, \
- .nmodule_search_path = -1}
+ .nmodule_search_path = -1, \
+ .isolated = -1, \
+ .site_import = -1, \
+ ._install_importlib = 1}
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */
/* Placeholders while working on the new configuration API