-
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
Fixes #1807: 2.3.0 regression: <class 'bytes'> -> std::vector<uint8_t> #2198
base: master
Are you sure you want to change the base?
Conversation
@@ -144,7 +144,7 @@ template <typename Type, typename Value> struct list_caster { | |||
using value_conv = make_caster<Value>; | |||
|
|||
bool load(handle src, bool convert) { | |||
if (!isinstance<sequence>(src) || isinstance<str>(src)) | |||
if (!isinstance<sequence>(src) || (!isinstance<bytes>(src) && isinstance<str>(src))) |
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 believe this only cures a symptom of a bigger problem, pointed out to me by @bstaletic :
77059f0
With that change, the code here can stay as-is.
@wjakob Did you attempt work based on @jagerman 's code, or do you know if anyone else tried?
@cdump While I think it's best to not change this line here, your test looks valuable to me. I'm in favor of merging it after the more fundamental issue is fixed.
…rent behavior. Basis for discussing actual desired behavior. Background: * pybind@77059f0 * pybind#2198
…rent behavior. Basis for discussing actual desired behavior. Background: * pybind@77059f0 * pybind#2198
…rent behavior. Basis for discussing actual desired behavior. Background: * pybind@77059f0 * pybind#2198
In connection with precursors of #2409, we had discussions about the behavior change in this PR, with ~3 different ideas for what behavior is desired. My thinking:
Rationale: In Python 2, plain string literals are I believe this thinking is in line with #1298, which added the |
I'm not sure I'm happy with introducing differences between Python 2 and Python 3, though. Especially now. As you say, in Python 2, The thing is:
|
Oh, what about a different solution that would satisfy both? What if we allow the conversion from |
I'm guessing implementing that will be significantly more complex than the currently very simple change, that complexity will still be there even after Python 2 is truly dead, and we will get complaints that EDIT - WARNING: In the meantime I discovered that something is very fishy in the environment I'm testing in. I'm debugging. Please ignore the below for the minute. In the interest of getting the story right for Python 3 as soon as possible, I'm OK to accept the potential pitfall for Python 2. But when I just tried this PR locally with Python 2, I'm getting failures of existing tests in @cdump, could you please rebase this PR on current master and push to your fork? That will trigger our fancy new CI system, which I expect to surface the same failures. |
It turns out just adding this one line in
More precisely, if you look here: https://github.com/pybind/pybind11/pull/2711/commits:
It seems pretty certain that we have a bug on master, unrelated to the change in this PR, except that the one new line in Unfortunately that existing bug makes it difficult to work on this PR. |
After some quick trial-and-error, it looks like some sort of crosstalk between the use of |
I wonder if it has to do with this: https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#making-opaque-types Maybe there needs to be a |
… to std::vector<uint8_t> anymore
Sorry about the delay; busy end of November!
Oh right, I thought we were just talking about "what behavior do we want?", but I didn't realize tests were failing :-( |
I was looking into this, getting a "warning: type ‘struct type_caster’ violates the C++ One Definition Rule [-Wodr]" warning, and @bstaletic rightly suggested that we have conflicting caster instantiations. |
That's interesting, what exactly did you do to get that warning? |
I really just (re)compiled it, almost ignored it, then noticed something fishy. Making progress, btw, but it's kind of annoying that we can't check |
Only if super easy, so I don't have to guess platform, compiler, exact command: could you email me the command and build log?
I was under the impression it's possible, but maybe/apparently only if the bindings live in different extension modules (.so)? |
Sure, but I'm not sure it's going to be an obvious help for you. Let me try to reproduce :-)
Yes, you're right. I meant in the current version of the tests in a single extension module. This doesn't feel important enough to start throwing around the tests' design for, but yes it's peculiar. I would assume it's maybe slightly less of a hassle and more efficient to create 1 file than to create a couple of dozen? |
Fixes 2.2.4 -> 2.3.0+ regression #1807
Introduced by e76dff7