Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PEP 587: PyConfig_InitPythonConfig() cannot fail anymore #1187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2019
Merged
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
33 changes: 10 additions & 23 deletions pep-0587.rst
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,9 @@ Example setting the program name::
void init_python(void)
{
PyStatus status;
PyConfig config;

status = PyConfig_InitPythonConfig(&config);
if (PyStatus_Exception(status)) {
goto fail;
}
PyConfig config;
PyConfig_InitPythonConfig(&config);

/* Set the program name. Implicitly preinitialize Python. */
status = PyConfig_SetString(&config, &config.program_name,
Expand All @@ -382,9 +379,9 @@ Example setting the program name::

``PyConfig`` methods:

* ``PyStatus PyConfig_InitPythonConfig(PyConfig *config)``
* ``void PyConfig_InitPythonConfig(PyConfig *config)``
Initialize configuration with `Python Configuration`_.
* ``PyStatus PyConfig_InitIsolatedConfig(PyConfig *config)``:
* ``void PyConfig_InitIsolatedConfig(PyConfig *config)``:
Initialize configuration with `Isolated Configuration`_.
* ``PyStatus PyConfig_SetString(PyConfig *config, wchar_t * const *config_str, const wchar_t *str)``:
Copy the wide character string *str* into ``*config_str``.
Expand Down Expand Up @@ -596,12 +593,9 @@ configuration, and then override some parameters::
PyStatus init_python(const char *program_name)
{
PyStatus status;
PyConfig config;

status = PyConfig_InitPythonConfig(&config);
if (PyStatus_Exception(status)) {
goto done;
}
PyConfig config;
PyConfig_InitPythonConfig(&config);

/* Set the program name before reading the configuration
(decode byte string from the locale encoding).
Expand Down Expand Up @@ -684,12 +678,9 @@ Example of customized Python always running in isolated mode::
int main(int argc, char **argv)
{
PyStatus status;
PyConfig config;

status = PyConfig_InitPythonConfig(&config);
if (PyStatus_Exception(status)) {
goto fail;
}
PyConfig config;
PyConfig_InitPythonConfig(&config);

config.isolated = 1;

Expand Down Expand Up @@ -859,13 +850,9 @@ phases::
void init_python(void)
{
PyStatus status;
PyConfig config;

status = PyConfig_InitPythonConfig(&config);
if (PyStatus_Exception(status)) {
PyConfig_Clear(&config);
Py_ExitStatusException(status);
}
PyConfig config;
PyConfig_InitPythonConfig(&config);

config._init_main = 0;

Expand Down