8000 bpo-45445: Fail if an invalid X-option is provided in the command line by pablogsal · Pull Request #28823 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-45445: Fail if an invalid X-option is provided in the command line #28823

New issue 8000

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 6 commits into from
Oct 13, 2021
Prev Previous commit
Next Next commit
fixup! fixup! Fail if an invalid X-option is provided in the command …
…line
  • Loading branch information
pablogsal committed Oct 12, 2021
commit 20dd7561a9675b76b1ec5f1a68f28418825f827c
4 changes: 4 additions & 0 deletions Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,10 @@ _PyConfig_InitImportConfig(PyConfig *config)
return config_init_import(config, 1);
}

// List of known xoptions to validate against the provided ones. Note that all
// options are listed, even if they are only available if a specific macro is
// set, like -X showrefcount which requires a debug build. In this case unknown
// options are silently ignored.
const wchar_t* known_xoptions[] = {
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind to add a comment saying that all options are listed, even if they are only available if a specific macro is set, like -X showrefcount which requires a debug build (Py_REF_DEBUG). Say that unknown options are silently ignored in this case.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

L"faulthandler",
L"showrefcount",
Copy link
Member

Choose a reason for hiding this comment

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

Should Python ignore silently this option if Python is not build with Py_REF_DEBUG? Or should we add #ifdef Py_REF_DEBUG? Using PYTHONDUMPREFS=1 env var doesn't fail with an error even if Python is not build with Py_TRACE_REFS.

IMO the least surprising behavior is to ignore silently the option. So leave the code as it is.

Expand Down
0