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

regression: event header can't be copied with normal Python syntax. #112

Closed
kdart-brt opened this issue Oct 12, 2020 · 8 comments
Closed

Comments

@kdart-brt
Copy link

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'

@pquentin
Copy link

@kdart-brt The way headers work has changed with #104 which was released recently

@tomchristie
Copy link
Contributor

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:

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)

@kdart-brt
Copy link
Author

That alternate list constructor works. So, whatever you do is fine by me.

@pquentin
Copy link

👍 on the simple amendment

@kdart-brt
Copy link
Author

BTW, thanks for the help.

@tomchristie
Copy link
Contributor

You're very welcome. 💛

@pgjones
Copy link
Member

pgjones commented Dec 27, 2020

Does #125 help this?

@tomchristie
Copy link
Contributor

Does #125 help this?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants