-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
make wsgiref.headers.Headers accept empty constructor #50050
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
Comments
wsgiref.headers.Headers will let you manage a collection of HTTP >>> from wsgiref.headers import Headers A logical change would be to allowed creating an empty Headers instance: >>> from wsgiref.headers import Headers |
Patch attached. While I was at it, I also removed stupid whitespace and |
Added a pointer from bpo-5801 to here. |
Correct and update patch + update test case |
here is the updated test case |
I applied the patches for wsgiref.headers and test_headers.py, ran the test with runtests.sh test_headers.py and it passed. I also tried the code in the description:
|
FTR, note that “svn diff file1 file2...” will give you one file for many edits. It’s easier to review and apply. Regarding the change, I don’t know if wsgiref 3.2 has to be compatible with Python 2.1, which would exclude using the ternary operation. The change from type to isinstance will probably be rejected, since WSGI does not accept subclasses for the things it defines. |
Yes, please consider the type->isinstance part of the change rejected. I just got done reverting a bunch of those in 3.2. Where WSGI specifies types, it means "type() is", not "isinstance". (The 3.x version of wsgiref does not need to be executable on 2.x versions, but this doesn't mean the protocol itself can be altered in backwards-incompatible ways, just the implementation.) |
Do I have to resubmit the patch or can you use the existing one? |
Re-submitting the patch for Lib/wsgiref/headers.py w/o the isinstance change |
Here is the correction for the docs. I would love to see this making it into 3.2 release. |
I reviewed the patch.
All in the revision 86742. |
LGTM. |
Here's the single-file patch against the revision. |
Looks good to me. |
|
I think the doc should say something like “default value is an empty list”, for maximum clarity. |
This shouldn't be languishing, work has been committed against revision 86742 and there's another patch that apparently just needs a little tweak. |
The patch is not committed yet. $ ./python
Python 3.5.0a0 (default:979aaa08c067+, Jun 19 2014, 13:01:36)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wsgiref.headers import Headers
>>> h = Headers()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() missing 1 required positional argument: 'headers' Here's an updated patch that addresses Éric's review (and without cosmetic changes to make review easier). |
Just for the record clicking on "revision 86742" gives "Specified revision r86742 not found". |
Here's a new patch with a whatsnew entry. David, could you review the patch? |
Patch updated. If there's no objections, I'll commit this patch in the next couple of days. |
Since we don't need to avoid new language features, using the ternary would be better than using the or. This is exactly the sort of situation the ternary was introduced for: making sure the input really is None before applying the default. Otherwise the patch looks good. |
New changeset a91f0d4a2381 by Berker Peksag in branch 'default': |
Thanks for the patch and review. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: