Oliver Sanders [Tue, 22 Apr 2025 17:19:00 +0000 (18:19 +0100)]
websockets: fix ping_timeout (#3376)
* websockets: fix ping_timeout
* Closes #3258
* Closes #2905
* Closes #2655
* Fixes an issue with the calculation of ping timeout interval that
could cause connections to be erroneously timed out and closed
from the server end.
Ben Darnell [Thu, 27 Mar 2025 20:30:08 +0000 (16:30 -0400)]
httputil: Make parse_request_start_line stricter
The method is now restricted to being valid token characters as defined
in RFC 9110, allowing us to correctly issue status code 400 or 405
as appropriate (this can make a difference with some caching proxies).
The request-target no longer allows control characters. This is less
strict than the RFC (which does not allow non-ascii characters),
but prioritizes backwards compatibility.
Ben Darnell [Thu, 27 Mar 2025 20:22:33 +0000 (16:22 -0400)]
httputil: Centralize regexes based directly on RFCs
This will make it easier to stay in strict conformance with the RFCs.
Note that this commit makes a few small semantic changes to response
start-line parsing: status codes must be exactly three digits, and
control characters are not allowed in reason phrases.
Ben Darnell [Fri, 28 Feb 2025 02:45:49 +0000 (21:45 -0500)]
ci: Add a cibuildwheel test run to test.yml
This lets us test the cibuildwheel workflow independently of the
infrequently-run build.yml. It also gives us an easy way to test
freethreading builds.
Ben Darnell [Thu, 20 Feb 2025 22:47:25 +0000 (17:47 -0500)]
Merge pull request #3461 from bdarnell/deprecations-314
Python 3.14 deprecates the asyncio event loop policy system, so make (most of) the necessary changes.
The deprecation of set_event_loop is extremely disruptive to AsyncTestCase, so I've asked if it can remain undeprecated in python/cpython#130322. The testing.py changes are temporary until this is resolved.
Ben Darnell [Thu, 20 Feb 2025 19:22:14 +0000 (14:22 -0500)]
testing: Suppress deprecation warnings in AsyncTestCase
This is a temporary measure to get CI passing while the fate of these
deprecation warnings is decided in
https://github.com/python/cpython/issues/130322
Ben Darnell [Wed, 19 Feb 2025 19:43:04 +0000 (14:43 -0500)]
asyncio_test: Remove obsolete cleanup logic
Per comments, we needed to set and restore the event loop policy
in Python 3.4, but it no longer seems to be necessary (and
raises DeprecationWarnings in Python 3.14).
Ben Darnell [Thu, 21 Nov 2024 19:48:05 +0000 (14:48 -0500)]
httputil: Fix quadratic performance of cookie parsing
Maliciously-crafted cookies can cause Tornado to
spend an unreasonable amount of CPU time and block
the event loop.
This change replaces the quadratic algorithm with
a more efficient one. The implementation is copied
from the Python 3.13 standard library (the
previous one was from Python 3.5).
Fixes CVE-2024-52804
See CVE-2024-7592 for a similar vulnerability in cpython.
Ben Darnell [Thu, 21 Nov 2024 19:50:36 +0000 (14:50 -0500)]
ioloop_test: Skip a test that no longer works on py3.14
This test uses implicit event loop creation but
avoided deprecation warnings because it ran in a
subprocess. Surprisingly, it is the only test we
have left for this pattern.
Ben Darnell [Thu, 24 Oct 2024 13:33:13 +0000 (09:33 -0400)]
setup: Remove override of bdist_wheel
This is no longer necessary in recent versions of setuptools
(and we now check that abi3 is used properly in official releases).
The bdist_wheel implementation is being moved from the wheel package
into setuptools so overriding it will stop working in the future.
Follows the example of https://github.com/joerick/python-abi3-package-sample/pull/30
Ben Darnell [Wed, 4 Sep 2024 19:14:30 +0000 (15:14 -0400)]
docs: Add readthedocs configuration
RTD will no longer do this automagically, so we need to add these
lines explicitly for compatibility. See
https://about.readthedocs.com/blog/2024/07/addons-by-default/
Colin Watson [Sun, 18 Aug 2024 17:58:11 +0000 (18:58 +0100)]
Fix tests with Twisted 24.7.0
`twisted.internet.defer.returnValue` was needed on Python 2, but on
Python 3 a simple `return` statement works fine. Twisted 24.7.0
deprecated the former, causing
`tornado.test.twisted_test.ConvertDeferredTest.test_success` to fail.
Ben Darnell [Thu, 11 Jul 2024 18:28:10 +0000 (14:28 -0400)]
test: Remove broken tests for legacy TLS versions
The get_ssl_version method in these tests has been
silently ignored for a long time (forever?) due to
MRO issues (if they weren't ignored, they'd have
started throwing deprecation warnings), and they
were never updated for more recent versions of
TLS. There doesn't appear to be much value in
rehabilitating these tests so just get rid of all
but the base configuration.
build(deps): bump certifi from 2024.6.2 to 2024.7.4
Bumps [certifi](https://github.com/certifi/python-certifi) from 2024.6.2 to 2024.7.4.
- [Commits](https://github.com/certifi/python-certifi/compare/2024.06.02...2024.07.04)
Ben Darnell [Fri, 28 Jun 2024 20:27:55 +0000 (16:27 -0400)]
test: Replace a long-skipped test for tornado.util.exec_in
This test was first written to rely on the print_function future import
in Python 2.7, so it's been skipped since we dropped Python 2.
Use the annotations future import introduced in Python 3.7 instead.
Ben Darnell [Thu, 13 Jun 2024 19:25:50 +0000 (15:25 -0400)]
*: Switch from percent formatting to f-strings
Automated change using pyupgrade in two passes (once to go from percent
formatting to str.format, then to go from str.format to f-strings),
followed by black.
This left a few uses of str.format for unknown reasons.