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

bpo-39573: Use Py_IS_TYPE for type checking #18789

Closed
wants to merge 2 commits into from
Closed

bpo-39573: Use Py_IS_TYPE for type checking #18789

wants to merge 2 commits into from

Conversation

petdance
Copy link
Contributor

@petdance petdance commented Mar 5, 2020

This finishes up the conversions to using Py_IS_TYPE for checking object types.

It also updates Py_IS_TYPE(ob, type) to be able to take a const objects and a const type.

https://bugs.python.org/issue39573

return ob->ob_type == type;
}
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST(ob), type)
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to have a new private _PyObject_CAST_CONST() macro rather than casting directly.

I prefer macros because maybe tomorrow we might be able to check if the pointer is valid PyObject in debug mode. Maybe using _PyObject_CheckConsistency().

Would you mind to move these changes (add the macro and modify Py_IS_TYPE to use const) into a separated PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll make two separate PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are now in #18798 and #18799

@vstinner
Copy link
Member

vstinner commented Mar 6, 2020

I merged PR #18809.

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.

None yet

4 participants