-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: avoiding usage of _ if already defined #3423
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
Conversation
abb94d5
to
9b374b0
Compare
This is a majorly backwards incompatible change because it breaks documented practices for custom type casters since pretty much forever (see https://pybind11.readthedocs.io/en/stable/advanced/cast/custom.html, and the fact that you had to change the custom casters in test code to get it to compile). |
Didn't realize this was so public, but was mostly playing around to see what it would take. The Also, am I correct in my assessment that it's really just for compile time manipulatable strings? Found some useful docs improvements that I'll probably pull out. |
I might try the "_" only if no macro exists idea. |
9b374b0
to
40e0b9a
Compare
This renames |
It's been a while, but yes, as I recall, that is the main purpose -- by being compile-time constants they can avoid getting compiled into the actual final code. I think @wjakob probably chose Replacing it for 3.0 definitely seems good to me; in the meantime, perhaps it could go behind an opt-in macro? |
The current system seems pretty safe and backward compatible; both Basically it's an opt-out macro, and the macro is exactly the thing it collides with anyway. |
1689cca
to
b4a7859
Compare
This needs a doc update, too: the |
Do we want to change the docs over? I think it's more readable, so I'd be in favor. We can leave |
I'm strongly in favor if changing the docs to |
35493c9
to
b5b5f43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Randomly crossed my mind:
const_char_array
would be a more truthful / expressive name.
py::str
is something completely different from py::detail::const_str
.
Kind of, but the point of this function isn't to be a const char array, it's meant only to be a compile-time static name for a class, and being a const char array just happens to be the current implementation detail. So perhaps |
I think the overlap between
I can add a test. I'm wondering if adding a |
|
655372b
to
0c119d2
Compare
So |
Const name is my strong favorite
(Typing on my phone)
…On Fri, Dec 17, 2021 at 12:26 Henry Schreiner ***@***.***> wrote:
So const_str, const_name, and type_name (which I missed from before).
—
Reply to this email directly, view it on GitHub
<#3423 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFUZAAKL5GKD2GPHU2POWTUROMHVANCNFSM5G5SOKAQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just took another look. Perfect, thanks a lot for doing this!
Can I get one more approval? @jagerman, @Skylion007, or someone else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Also exercises pybind11::detail::_ backward compatibility. See also: PR pybind#3423
* Adding dedicated test_const_name. Also exercises pybind11::detail::_ backward compatibility. See also: PR #3423 * Backing out tests involving int_to_str (requires C++17 or higher). * Suppressing clang-tidy errors. * Disabling test_const_name for MSVC 2015 due to bizarre failures. * Stacking @pytest.mark.parametrize (thanks to @Skylion007 for pointing out).
…1_protobuf. This is a functional no-op. Note that `_` was deprecated already in Dec 2021 (pybind/pybind11#3423). PiperOrigin-RevId: 574885200
…1_protobuf. This is a functional no-op. Note that `_` was deprecated already in Dec 2021 (pybind/pybind11#3423). PiperOrigin-RevId: 574885200
…1_protobuf. This is a functional no-op. Note that `_` was deprecated already in Dec 2021 (pybind/pybind11#3423). PiperOrigin-RevId: 575085924
…1_protobuf. This is a functional no-op. Note that `_` was deprecated already in Dec 2021 (pybind/pybind11#3423). PiperOrigin-RevId: 575085924
Description
Closes #3401 by avoiding using a raw
_
.Suggested changelog entry: