Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 5, 2024

_PyConfig_AsDict() now returns bool objects for options using the new PyConfig_MEMBER_BOOL type.

Update tests for these changes.

_PyConfig_AsDict() now returns bool objects for options using the new
PyConfig_MEMBER_BOOL type.

Update tests for these changes.
@vstinner
Copy link
Member Author

vstinner commented Mar 5, 2024

cc @swtaarrs

'code_debug_ranges': 1,
'show_ref_count': 0,
'dump_refs': 0,
'cpu_count': -True,
Copy link
Member

Choose a reason for hiding this comment

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

cpu_count is still an int, so I think this change is wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, fixed. I blindly replaced 0 with False and 1 with True :-)

Comment on lines +1304 to 1311
if (spec->type == PyConfig_MEMBER_BOOL
|| spec->type == PyConfig_MEMBER_UINT)
{
if (value < 0) {
config_dict_invalid_value(spec->name);
return -1;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth also verifying that value <= 1 for BOOL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, PyConfig_Read() doesn't normalize boolean values to (0, 1). I prefer to tolerate values larger than 1 for now.

The main reason for this change is to return bool in _PyConfig_AsDict().

@vstinner vstinner enabled auto-merge (squash) March 6, 2024 09:05
@vstinner vstinner merged commit 2b37996 into python:main Mar 6, 2024
@vstinner vstinner deleted the pyconfig_bool branch March 6, 2024 09:29
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…n#116359)

_PyConfig_AsDict() now returns bool objects for options using the new
PyConfig_MEMBER_BOOL type.

Update tests for these changes.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…n#116359)

_PyConfig_AsDict() now returns bool objects for options using the new
PyConfig_MEMBER_BOOL type.

Update tests for these changes.
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.

2 participants