Skip to content

gh-158942: Use more unique variable names in Py_MIN/MAX/ABS() - #158969

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:pymin_var_name
Oct 8, 2026
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:pymin_var_name

Conversation

@vstinner

@vstinner vstinner commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

If Py_MIN/MAX/ABS() macros are called on an existing "_x" or "_y" variable name, the macro local variables may be overriden by the external variables. So use more unique names in the macros.

Add test_min_max_abs_macros() to _testlimitedcapi.

If Py_MIN/MAX/ABS() macros are called on an existing "_x" or "_y"
variable name, the macro local variables may be overriden by the
external variables. So use more unique names in the macros.

Add test_min_max_abs_macros() to _testlimitedcapi.
@vstinner

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

cc @lpyu001 @ZeroIntensity

@lpyu001

lpyu001 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

If the other compatibility changes are considered acceptable, I have no objection to this change.

For reference, I also used an LLM to scan 1,561 PyPI packages with C extensions and found only one case of nested Py_MIN() usage, in librt.

@vstinner
vstinner enabled auto-merge (squash) October 8, 2026 17:21
@vstinner
vstinner merged commit e2c3c7e into python:main Oct 8, 2026
52 checks passed
@vstinner
vstinner deleted the pymin_var_name branch October 8, 2026 17:48
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