cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-99201: fix IndexError when initializing sysconfig config variables

Open FFY00 opened this issue 2 years ago • 3 comments

  • Issue: gh-99201

FFY00 avatar Nov 09 '22 03:11 FFY00

@philthompson10, can you confirm this fixes your issue?

FFY00 avatar Nov 09 '22 03:11 FFY00

On 09/11/2022 03:36, Filipe Laíns wrote:

@philthompson10, can you confirm this fixes your issue?

Yes but I think a safer fix would be to set vars['EXT_SUFFIX'] to None or ''. There might be code that is expecting the dict to have a value with that key (as it currently does in all circumstances) and also that that value is a string.

Phil

philthompson10 avatar Nov 09 '22 09:11 philthompson10

The existence of EXT_SUFFIX is not guaranteed, as it is not documented anywhere. People expecting it to be there is the reason why I think we shouldn't set it at all. Returning None will make code that uses the string value of the returned object misbehave (eg. f'my_extension{sysconfig.get_config_var("EXT_SUFFIX")}' will be my_extensionNone), so raising a KeyError in these situations is more desirable.

FFY00 avatar Nov 10 '22 00:11 FFY00