regression: event header can't be copied with normal Python syntax.
I have been using h11 for a while now. In my code, I made a copy of the headers like this:
headers = ev.headers[:]
That is the normal way to copy a list (headers was a list).
Now, after an update, it does this: ValueError: too many values to unpack (expected 3)
in debugger, the same: 1:Debug:1/2> ev.headers[:] *** ValueError: too many values to unpack (expected 3)
Something changed in the headers attrbibute. It also does not have a copy method.
1:Debug:1/2> ev.headers.copy()
*** AttributeError: 'Headers' object has no attribute 'copy'
@kdart-brt The way headers work has changed with https://github.com/python-hyper/h11/pull/104 which was released recently
Right, so the intent was not to cause any regressions in how we approached #104, but that's obviously not quite been the case here, since you've found a wrinkle.
The change here is that the requirement in #104, of "allow h11 to expose the original header casing" meant that we've needed to change headers from a list to a sequence-like interface in the 0.11 release.
There's two options for us here:
- Issue an amendment in https://h11.readthedocs.io/en/latest/changes.html#v0-11-0-2020-10-05 to make that explicit.
- Change the
Headersdata structure so that we're ensuring it has a fully list-like interface, rather than simple a sequence interface.
Of those two I'd probably tend towards the first.
From a user POV that'd mean using the following if you want a list-copy of the structure...
headers = list(ev.headers)
That alternate list constructor works. So, whatever you do is fine by me.
👍 on the simple amendment
BTW, thanks for the help.
You're very welcome. 💛
Does #125 help this?
Does https://github.com/python-hyper/h11/pull/125 help this?
Yes.