Skip to content
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

GH-93262: Better error message for -X option #93264

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented May 26, 2022

Closes #93262

@@ -2085,6 +2085,11 @@ config_read(PyConfig *config, int compute_path_config)
/* -X options */
const wchar_t* option = _Py_check_xoptions(&config->xoptions, known_xoptions);
if (option != NULL) {
if ((wcslen(option) * sizeof(wchar_t)) < 100) {
static char error_msg[150];
Copy link
Member

@vstinner vstinner May 26, 2022

Choose a reason for hiding this comment

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

This variable will always be allocated even if there is no error, and it's reserved for this exact line of code. I'm not really excited by this implementation.

@pablogsal wanted to do something similar when he wrote the option.

Moreover, PyStatus API uses a bytes string, whereas the option is a wide character string. I expect encoding issues :-(

Copy link
Contributor Author

@kumaraditya303 kumaraditya303 May 27, 2022

Choose a reason for hiding this comment

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

This variable will always be allocated even if there is no error, and it's reserved for this exact line of code.

It is a static variable so it will be in bss segment.

Moreover, PyStatus API uses a bytes string, whereas the option is a wide character string. I expect encoding issues :-(

It is just to help the user of typos, it does not need to account for every locale or encoding IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants