Closed Rosuav closed 8 months ago
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 ImportError: cannot import name 'CloseCode' from 'websockets.frames'
, when running tests on the main branch.
Other implementations? If you mean the fact that I put this into the legacy/
directory, that seems to be where this happens, regardless of how it's called upon. My original code (where I ran into this problem) uses async with websockets.serve(..., process_request=...)
and has that function asynchronously return the three-tuple.
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 int
to HTTPStatus
is happening here:
And there is already a test for this behavior: https://github.com/python-websockets/websockets/blob/f62d44ac1a0a606fe5753cf0017ce9e1dbf3640e/tests/legacy/test_client_server.py#L766-L772
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
.