← 返回首页
gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec by vstinner · Pull Request #116359 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec#116359

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:pyconfig_bool
Mar 6, 2024
Merged

gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec#116359
vstinner merged 5 commits into
python:mainfrom
vstinner:pyconfig_bool

Conversation

vstinner commented Mar 5, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

_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 commented Mar 5, 2024

Copy link
Copy Markdown
Member Author

cc @swtaarrs

Comment thread Lib/test/test_embed.py Outdated
'code_debug_ranges': 1,
'show_ref_count': 0,
'dump_refs': 0,
'cpu_count': -True,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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

Comment thread Python/initconfig.c
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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 enabled auto-merge (squash) March 6, 2024 09:05
vstinner merged commit 2b37996 into python:main Mar 6, 2024
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Footer

© 2026 GitHub, Inc.