PEP 484: Do not require type checkers to treat a None default specially by JelleZijlstra · Pull Request #689 · python/peps (original) (raw)

by setting None (NULL) instead of "none" for ENCODING

reported by Andrey Oparin andrey@edsd.com

move simple_httpclient test_gzip to the shared httpclient tests, to test the decompress_response option for curl_httpclient as well

"Implicit-optional" mode is on by default, but that default is intended to change in the indefinite future (python/peps#689, python/typing#275). Go ahead and change to the future explicit use of Optional.

See also: commit a237a99

CancelledError is now always considered "quiet" (and concurrent.futures.CancelledError is no longer the same as asyncio.CancelledError).

Fixes tornadoweb#2677

Mark CancelledError change as 6.0.3

Where possible, replace use of errno with the exception hierarchy available since python 3.3. Remove explicit handling of EINTR which has been automatic since python 3.5

This happens in docker with default configurations and is generally harmless.

Fixes tornadoweb#2274

Root is always allowed to bind to low port numbers, so we can't simulate failure in this case. This is the last remaining failure when running tests in docker.

Fixes tornadoweb#2608

Fixes: tornadoweb#2689

Tornado is now py3-only so @lru_cache is always available.

Performance is about the same. Benchmark below. Python 3.7 on Linux.

before, cached: 0.9121252089971676 before, uncached: 13.358482279989403

after, cached: 0.9175888689933345 after, uncached: 11.085199063003529

from time import perf_counter

names = [f'sOMe-RanDOM-hEAdeR-{i}' for i in range(1000)]

from tornado.httputil import _normalize_header
start = perf_counter()
for i in range(10000):
    # _normalize_header.cache_clear()
    for name in names:
        _normalize_header(name)
print(perf_counter() - start)

from tornado.httputil import _NormalizedHeaderCache
start = perf_counter()
_normalized_headers = _NormalizedHeaderCache(1000)
for i in range(10000):
    # _normalized_headers = _NormalizedHeaderCache(1000)
    for name in names:
        _normalized_headers[name]
print(perf_counter() - start)

This is slightly faster than using the builtin cache, e.g.:

With benchmark below (Python 3.7, Linux):

before: 0.7284867879934609 after: 0.2657967659761198

import re
from time import perf_counter

line = 'HTTP/1.1'

_http_version_re = re.compile(r"^HTTP/1\.[0-9]$")

start = perf_counter()
for i in range(1000000):
    _http_version_re.match(line)
print(perf_counter() - start)

start = perf_counter()
for i in range(1000000):
    re.match(r"^HTTP/1\.[0-9]$", line)
print(perf_counter() - start)

This test started failing on windows CI with an upgrade to python 3.7.4 (which bundles a newer version of openssl). Disable tls 1.3 for now.

Possibly related to tornadoweb#2536

assertEquals() is deprecated, and python3.7/pytest can warn about it

support x-www-form-urlencoded body with values consisting of encoded bytes which are not url-encoded into ascii (it seems other web frameworks often support this)

add bytes qs support to escape.parse_qs_bytes, leave str qs support for backwards compatibility

This function is called on more than just 304 responses; it’s important to permit the Allow header on 204 responses. Also, the relevant RFCs have changed significantly.

Fixes tornadoweb#2726.

Signed-off-by: Anders Kaseorg andersk@mit.edu

Previously, only the part before the first '(' would be correctly unescaped.

Bumps twisted from 19.2.1 to 19.7.0.

Signed-off-by: dependabot[bot] support@github.com

Added an extra set for handling dead links, and reporting.

One consequence of this is that using this script will "work" offline, but will report that some all the links were not fetched.

A new release of black changed the way some of our files are formatted, so use a fixed version in CI.

Updates tornadoweb#2765

Reduce tox matrix to one env per python version, with two extra builds for lint and docs. Delegate to tox from travis-ci.

Add 3.8 to testing. Simplify by dropping coverage reporting and "no-deps" test runs.

fixes tornadoweb#2771

Addresses tornadoweb#2776.

This requires moving some noqa comments due to 3.8's changes to the ast module.

This required some minor code changes, mainly some adjustments in tests (which are now analyzed more thoroughly in spite of being mostly unannotated), and some changes to placement of type:ignore comments.

This ensures that the tests pass on Windows regardless of the user's git CRLF settings.

This gets most of the tests working again on windows with py38.

Alternate resolvers behave differently on this platform for unknown reasons.

This name is not present on all platforms

This makes it possible for tests to be a little more precise, and also makes them less dependent on exactly how the test is run (runtests.py sets the logging level to info, but when running tests directly from an editor it may use the default of warnings-only).

CI only runs the tests with runtests.py, so this might regress, but I'm not building anything to prevent that yet (options include running the tests differently in CI or making ExpectLog always use a fixed log configuration instead of picking up the current one)

fixes issue that a read may fail with StreamClosedError if stream is closed mid-read

_start_read can resolve with _try_inline_read, which can succeed even if the stream has been closed if the buffer has been populated by a prior read

preserve the fix for asserts being hit when dealing with closed sockets

Updates tornadoweb#2719

.org still allows this for some reason

Update comment from tornadoweb#2690 about ssl module exceptions.

The User-Agent format is "Tornado{Tornado_Version}".

If self.request.user_agent isn't set and self.request.headers has no User-Agent in it's keys the default User-Agent is added.

Fixes: tornadoweb#2702

This reverts commit e7e31e5.

We were using conda to get access to python 3.7 before rtd supported it in their regular builds, but this led to problems pinning a specific version of sphinx. See readthedocs/readthedocs.org#6870

Not sure why this has recently started happening in some environments, but killing a process too soon causes the wrong exit status in some python builds on macOS.

Its README says it is mostly obsolete due to improvements in virtualenv. Using it appears to cause problems related to pypa/setuptools#1934 because virtualenv installs the wheel package by default but venv doesn't.

Originally from tornadoweb#2831, which went to the wrong branch.

The 1s timeout used here has become flaky with the introduction of a sleep (before the timeout even starts).

Continuation of tornadoweb#2811

The oauth2 version of authorize_redirect is no longer a coroutine, so don't use await in example code. The oauth1 version is still a coroutine, but one twitter example was incorrectly calling it with yield instead of await.

This function is obsolete: Since python 3.4, file descriptors created by python are non-inheritable by default (and in the event you create a file descriptor another way, a standard function os.set_inheritable is available).

The windows implementation of this function was also apparently broken, but this went unnoticed because the default behavior on windows is for file descriptors to be non-inheritable.

Fixes tornadoweb#2867

This functionality is now provided directly in the os module.

This test was flaky on appveyor. Also expand comments about what exactly the test is doing.

This restores curl's default behaviour: use environment variables.

This option was set to "" to disable proxy in 905a215 but curl uses environment variables by default.

Without this try/finally, if this test ever fails, errors can be reported in a confusing way.

Closing the file descriptor without removing the corresponding handler is technically incorrect, although the default IOLoops don't have a problem with it.

This commit removes the need for applications to work around the backwards-incompatible change to the default event loop. Instead, Tornado will detect the use of the windows proactor event loop and start a selector event loop in a separate thread.

Closes tornadoweb#2804

Running a whole event loop on the other thread leads to tricky synchronization problems. Instead, keep as much as possible on the main thread, and call out to a second thread only for the blocking select system call itself.

Use this on windows due to a log spam issue in asyncio.

Restarting the event loop to "cleanly" shut down a coroutine introduces other problems (mainly manifesting as errors logged while running tornado.test.gen_test). Replace the coroutine with a pair of callbacks so we don't need to do anything special to shut down without logging warnings.

The just-released version 0.3.0 is incompatible with our older pinned version of sphinx.

The just-released version 0.3.0 is incompatible with our older pinned version of sphinx.

On Python 3, utf-8 is the default python source code encoding. so, the coding cookies on files that specify utf-8 are not needed anymore.

modified:   tornado/_locale_data.py
modified:   tornado/locale.py
modified:   tornado/test/curl_httpclient_test.py
modified:   tornado/test/httpclient_test.py
modified:   tornado/test/httputil_test.py
modified:   tornado/test/options_test.py
modified:   tornado/test/util_test.py

@gen.coroutine deco allows non-yielding functions, so I reflected that in the type hint.

Requires usage of @typing.overload due to python/mypy#9435

On Python 3, super does not need to be called with arguments where as on Python 2, super needs to be called with a class object and an instance.

This commit updates the super usage using automated regex-based search and replace. After the automated changes were made, each change was individually checked before committing.

Signed-off-by: odidev odidev@puresoftware.com

instead of "uncaught exception" and then test timeout

to prevent silent failure when the websocket client gets a 3xx redirect response, because it does not currently support redirects

Partial fix for issue tornadoweb#2405

not just POST (but still not HEAD)

following the behavior of libcurl > 7.70

Using a connect_timeout or request_timeout of 0 was effectively invalid for simple_httpclient: it would skip the actual request entirely (because the bulk of the logic was inside "if timeout:"). This was not checked for or raised as an error, it just behaved unexpectedly.

Change simple_httpclient to always assert these timeouts are not None and to support the 0 value similar to curl (where request_timeout=0 means no timeout, and connect_timeout=0 means curl default 300 seconds which is very very long for a tcp connection).

not exactly true for curl_httpclient (libcurl uses a connect_timeout of 300 seconds if no connect timeout is set) but close enough

this caused an infinite loop in simple_httpclient

The asyncio event loop provides enough contextvars support out of the box for basic contextvars functionality to work in tornado coroutines, but not contextvars.reset. Prior to this change, each yield created a new "level" of context, when an entire coroutine should be on the same level. This is necessary for the reset method to work.

Fixes tornadoweb#2731

Python 3.9 changed the behavior of ThreadPoolExecutor at interpreter shutdown (after the already-tricky import-order issues around atexit hooks). Avoid these issues by managing the thread by hand.

Without this mypy would fail when run on windows.

Remove dependencies that are rarely used outside of tox. The main motivation is to give dependabot less to worry about when an indirect dependency has a security vulnerability.

This version attempts to resolve types found in type annotations, but in many cases it can't find them so silence a bunch of warnings. (Looks like deferred annotation processing will make this better but we won't be able to use that until we drop Python 3.6)

This way we don't have to install twisted into the docs build environment. Add some more detail while I'm here.

These were most interesting when the default resolver blocked the main thread. Now that the default is to use a thread pool, there is little if any demand for alternative resolvers just to avoid threads.

Every not existing translation file for the existing locales logged an error message: Cannot load translation for 'ps': [Errno 2] No such file or directory: '/usr/share/locale/ps/LC_MESSAGES/foo.mo'

When used with asyncio.Future, WaitIterator may skip indices in some cases. This is caused by multiple _return_result calls after another, without having the chain_future call finish in between. This is fixed here by not hanging on to the _running_future anymore, which forces subsequent _return_result calls to add to _finished, instead of causing the previous result to be silently dropped.

Fixes tornadoweb#2034

There is a small typo in tornado/netutil.py.

Should read authenticate rather than authentiate.

Fixes tornadoweb#2960

It was no longer used and always set to None.

Making sure that len(data) == data.nbytes by casting memoryviews to bytes.

Bumps jinja2 from 2.11.2 to 2.11.3.

Signed-off-by: dependabot[bot] support@github.com

Bumps pygments from 2.7.2 to 2.7.4.

Signed-off-by: dependabot[bot] support@github.com

Co-authored-by: Ben Darnell ben@bendarnell.com Co-authored-by: Zachary Sailer zachsailer@gmail.com Co-authored-by: Pierce Lopez pierce.lopez@gmail.com Co-authored-by: Robin Roth robin@rroth.de Co-authored-by: Petr Viktorin encukou@gmail.com Co-authored-by: Martijn van Oosterhout oosterhout@fox-it.com Co-authored-by: Michael V. DePalatis mike@depalatis.net Co-authored-by: Remi Rampin r@remirampin.com Co-authored-by: Ran Benita ran@unusedvar.com Co-authored-by: Semen Zhydenko simeon.zhidenko@gmail.com Co-authored-by: Anders Kaseorg andersk@mit.edu Co-authored-by: Bulat Khasanov afti@yandex.ru Co-authored-by: supakeen cmdr@supakeen.com Co-authored-by: John Bampton jbampton@users.noreply.github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jeff van Santen jeffreyavansanten@gmail.com Co-authored-by: Bruno P. Kinoshita kinow@users.noreply.github.com Co-authored-by: Gareth T garetht@users.noreply.github.com Co-authored-by: Min RK benjaminrk@gmail.com Co-authored-by: bn0ir gblacknoir@gmail.com Co-authored-by: James Bourbeau jrbourbeau@gmail.com Co-authored-by: Recursing buonanno.lorenzo@gmail.com Co-authored-by: Flavio Garcia piraz@candango.org Co-authored-by: Ben Darnell ben@cockroachlabs.com Co-authored-by: marc Co-authored-by: agnewee agnewee@gmail.com Co-authored-by: Jeff Hunter jeff@jeffhunter.me Co-authored-by: 依云 lilydjwg@gmail.com Co-authored-by: odidev odidev@puresoftware.com Co-authored-by: Sai Rahul Poruri rporuri@enthought.com Co-authored-by: jack1142 6032823+jack1142@users.noreply.github.com Co-authored-by: Amit Patel amitp@cs.stanford.edu Co-authored-by: Debby debby@glance.net Co-authored-by: = <=> Co-authored-by: Eugene Toder eltoder@users.noreply.github.com Co-authored-by: Florian Best best@univention.de Co-authored-by: Alexander Clausen alex@gc-web.de Co-authored-by: Tim Gates tim.gates@iress.com Co-authored-by: bfis b.fis@cern.ch Co-authored-by: Eugene Toder eltoder@gmail.com Co-authored-by: youguanxinqing youguanxinqing@qq.com Co-authored-by: kriskros341 krzysztofczuba884@gmail.com Co-authored-by: Mads R. B. Kristensen madsbk@gmail.com Co-authored-by: Sakuya dl@pbstu.com