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

Fix crash formatting error message #4809

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

Conversation

ngoldbaum
Copy link

@ngoldbaum ngoldbaum commented Jan 17, 2025

Summary of changes

Avoids an AttributeError on non-posix systems, where sys.abiflags isn't set.

Closes #4807

This code was originally authored by @abravalheri in #4424. I think the non-POSIX limitation was just missed there.

That PR didn't add tests for this error so I thought it was fair game to fix it without a test as well 🙃.

Pull Request Checklist

@@ -291,10 +291,15 @@ def _validate_py_limited_api(self) -> None:
raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'")

if sysconfig.get_config_var("Py_GIL_DISABLED"):
# sys.abiflags is only defined on POSIX
if getattr(sys, "abiflags", ""):
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you just mean to check that the attribute exists, and not the truthiness of its value.

Suggested change
if getattr(sys, "abiflags", ""):
if hasattr(sys, "abiflags"):

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

Successfully merging this pull request may close these issues.

[BUG] Error formatting error message in bdist_wheel on Windows
2 participants