Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Include/internal/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ typedef struct _PyPathConfig {
wchar_t *program_name;
/* Set by Py_SetPythonHome() or PYTHONHOME environment variable */
wchar_t *home;
/* isolated and no_site_import are used to set Py_IsolatedFlag and
/* isolated and site_import are used to set Py_IsolatedFlag and
Py_NoSiteFlag flags on Windows in read_pth_file(). These fields
are ignored when their value are equal to -1 (unset). */
int isolated;
int no_site_import;
int site_import;
} _PyPathConfig;

#define _PyPathConfig_INIT \
{.module_search_path = NULL, \
.isolated = -1, \
.no_site_import = -1}
.site_import = -1}
/* Note: _PyPathConfig_INIT sets other fields to 0/NULL */

PyAPI_DATA(_PyPathConfig) _Py_path_config;
Expand Down
12 changes: 4 additions & 8 deletions Include/pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,16 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *);
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);

PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(
_PyCoreConfig *config,
int *isolated,
int *no_site_import);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
PyAPI_FUNC(int) _PyCoreConfig_Copy(
_PyCoreConfig *config,
const _PyCoreConfig *config2);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(
_PyCoreConfig *config,
int *isolated,
int *no_site_import);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
const _PyCoreConfig *config);
PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);


PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read(
_PyMainInterpreterConfig *config,
Expand Down
32 changes: 28 additions & 4 deletions Include/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand Down Expand Up @@ -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. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't right, as the field gets set to the result of !Py_NoSiteFlag

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote "negative value of !Py_NoSiteFlag". Is that wrong?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"negative value" is ambiguous here because we're dealing with C integers rather than strict booleans, and arithmetic negation (-value) and logical negation (!value) do different things. Since this is C code, and the English spelling is ambiguous, just including the exact C expression in the comment is clearer than trying to express the operation as words.

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
Expand Down
Loading