-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixing pybind11::bytes() ambiguous overload issue and adding missing bytes type to test_constructors(). #2340
Conversation
Clue: the situation for |
Next clue: this makes things compile:
What I don't get is:
EDIT: Some digging into the git history might explain, though? |
One thing that comes to mind: in Python 2 |
pybind11/include/pybind11/pytypes.h Lines 1070 to 1072 in 1491c94
|
8d3fe95
to
d4818c2
Compare
…bytes type to test_constructors().
I morphed this PR from a demo for the Thanks @YannickJadoul for pointing out the fix! You will see that I'm changing |
Nice, getting some consistency/sanity into all of this :-) All in all, this seems fine to me, but I still want to see these two things answered (I'll dive into all blames and PRs) before I'm confident in saying that this is the way to go:
If anyone has any insights into this, though, do say so! |
Thanks Yannick, I strongly feel that these questions are best addressed in separate PRs. |
Oh, I see. I was/am a bit afraid of making things even more complicated, potentially forgetting to tie up loose ends. If
Right, I understand. Things have gotten complex very fast! Regardless of that, I have a suggestion: what if we'd make a longer-running |
I have mixed feelings.
That's really all. Branching adds a lot of friction. Generally, I don't have great experience with branching. Note also Bertrand Meyer's Agile class (edx), it calls out branching as one of the top bad ideas. To be completely thorough: the The chimera issue will be fixed with #2256, modified by following your suggestion to replace #2256 will be the only additional step after this PR needed to make I think branching will make this only more difficult, especially branching for this pure bug fix, and hopefully already the next step (#2256) will make things fall into place. |
Alright, Ralf and I have been going back in time 3 or 4 years, and found this in pybind11's history:
#464 introduced a rework of
We'll see in a later PR how easy it is to increase consistency here
This still needs to be investigated (another PR to try things out), but there is no reason that |
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.
In other words: let's get this in!
Merging into |
…bytes type to test_constructors(). (pybind#2340)
…bytes type to test_constructors(). (pybind#2340)
…bytes type to test_constructors(). (pybind#2340)
…bytes type to test_constructors(). (pybind#2340)
…bytes type to test_constructors(). (pybind#2340)
…bytes type to test_constructors(). (#2340)
…bytes type to test_constructors(). (#2340)
…bytes type to test_constructors(). (pybind#2340)
…s one file). The two other files changed with PR pybind#2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR pybind#2380.
…bytes type to test_constructors(). (#2340)
…s one file). The two other files changed with PR pybind#2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR pybind#2380.
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
…bytes type to test_constructors(). (#2340)
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
…bytes type to test_constructors(). (#2340)
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
…bytes type to test_constructors(). (#2340)
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
…bytes type to test_constructors(). (pybind#2340)
…2390) * Rolling back PR pybind#2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR pybind#2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR pybind#2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR pybind#2380.
…bytes type to test_constructors(). (#2340)
* Rolling back PR #2340 change to tests/test_pytypes.py (only this one file). The two other files changed with PR #2340 are not affected by this partial rollback. This partial rollback enables cherry-picking a commit from PR #2380. * test_constructors() fix for Python 2. Preparation for changing `pybind11::str` to only hold `PyUnicodeObject` (NOT also `bytes`). Currently test_constructors passes with Python 2 only because `pybind11::str` can also hold a Python 2 `PyStringObject` (or the equivalent `PyBytesObject` in Python 3). Changing the test to exercise conversions for `PyUnicodeObject` makes it consistent between Python 2 and 3, and removes this small obstacle to the planned `pybind11::str` change. Tests for `bytes` conversions will be added separately. * Adding test_constructors test for bytes, on top of cherry-picked commit from PR #2380.
Two of the additions work, but
pybind11::bytes(obj)
generates this compilation error (tested with c++11 & c++2a):