-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
Allow plain integers as HTTP status codes #1406
Conversation
Quick review notes:
|
Added a test, but either I'm running the tests wrongly, or there are other failures. Can someone check please? I'm getting failures in eleven tests, mostly Other implementations? If you mean the fact that I put this into the |
Thank you for the test case :-) My comment about "other implementations" was a note to myself to check the Sans-I/O and the threading implementation because they're probably vulnerable to the same issue. |
Other implementations: actually, websockets already contains similar code in the Sans-I/O implementation. This supports aligning the legacy implementation to this behavior, like you've done. |
The test that you added passes without code changes. The conversion from websockets/src/websockets/exceptions.py Line 338 in f62d44a
|
And there is already a test for this behavior: websockets/tests/legacy/test_client_server.py Lines 766 to 772 in f62d44a
|
The code and tests already support it but the types didn't reflect it. Refs #1406.
Are you sure it all works? I wasn't running into issues with a type checker, but with an AttributeError when it tried to get some piece of information from the enum (which wasn't on the plain int). |
I didn't work in the last release. It works in the release I made on Saturday. |
Since an IntEnum is largely equivalent to the corresponding integer, allow HTTP status codes to be specified as (eg)
200
rather thanhttp.HTTPStatus.OK
.