Ben Darnell [Tue, 15 Sep 2015 03:27:18 +0000 (23:27 -0400)]
Replace `gen.Multi` and `gen.multi_future` with `gen.multi`.
`multi_future` is awkward to type but is much more prominent
in native coroutines. The new function `multi` has a more
convenient name and delegates to either the YieldPoint
or Future version automatically.
For backwards compatibility, `multi_future` is still around,
and `Multi` was renamed to `MultiYieldPoint` so that we don't
have two different objects whose names differ only in case
(`Multi` is now an alias for `multi`).
Ben Darnell [Tue, 15 Sep 2015 02:42:41 +0000 (22:42 -0400)]
Import t.p.asyncio automatically when available in gen.
This makes the _wrap_awaitable infinite recursion less likely
to occur, although it could show up again when another coroutine
framework adopts PEP 492.
Ben Darnell [Mon, 14 Sep 2015 03:13:43 +0000 (23:13 -0400)]
Support coroutines compiled with cython
On Python 3.5, this means supporting awaitables that are not
iterables. On older versions of python, this includes
* In `@gen.coroutine`, recognizing cython's coroutines
via the backports_abc module.
* At various points in the gen module, recognize cython's
use of `StopIteration.args[0]` in place of `StopIteration.value`.
* Implementing Future.__await__ and _wrap_awaitable for
pre-3.3 versions of python.
Ben Darnell [Sun, 13 Sep 2015 17:15:06 +0000 (13:15 -0400)]
Make HTTPHeaders a subclass of MutableMapping ABC instead of dict.
This simplifies the implementation since MutableMapping is designed
for subclassing while dict has many special cases that need to be
overridden. In particular, this change fixes the setdefault()
method.
Martin Sucha [Fri, 7 Aug 2015 13:42:48 +0000 (15:42 +0200)]
Fix error handling in read_until_close
When a callback is supplied, the future is not created. Make sure
it is used only if it was initialized, otherwise we lose the
error that was originally raised.
Ali Ebrahim [Thu, 30 Jul 2015 20:57:27 +0000 (13:57 -0700)]
Content-Type for compressed StaticFileHandler file
The python mimetypes module used by StaticFileHandler will recognize
compression (gzip, bz2, etc.) as the file encoding, and will give the
mime type for the uncompressed file. This commit will fix this
behavior, so a gzip file will end up as application/gzip.
Additionally, unknown file types (or known file types compressed with
anything other than gzip) are served as application/octet-stream.
Ben Darnell [Fri, 17 Jul 2015 15:36:53 +0000 (11:36 -0400)]
Fix path traversal check in StaticFileHandler.
Previously StaticFileHandler would allow access to files whose name
starts with the static root directory, not just those that are actually
in the directory.
The bug was introduced in Tornado 3.1 via commits 7b03cd62fb and 60952528.
Ben Darnell [Sun, 5 Jul 2015 21:13:07 +0000 (17:13 -0400)]
Introduce `oneline` template whitespace mode.
This slightly-more-aggressive whitespace removal doesn't actually
save any space, but it removes the very conspicuous blank lines
that are often left around template directives.
Ben Darnell [Sun, 5 Jul 2015 02:40:23 +0000 (22:40 -0400)]
Reduce logging of errors inside IOStream (especially SSLError).
Coroutine-style usage converts most errors into StreamClosedErrors,
which are logged less noisily while still allowing the original error
to be seen via the new real_error attribute. SSL errors now typically
result in a single log line instead of a full stack trace.
Ben Darnell [Sun, 21 Jun 2015 17:57:28 +0000 (13:57 -0400)]
Clear __package__ in script run by autoreload CLI.
This prevents imports from incorrectly being interpreted as
relative to the 'tornado package, which would make the standard
'platform' module unimportable.
Greg Ward [Sun, 21 Jun 2015 14:29:45 +0000 (10:29 -0400)]
Tie the example for AsyncHTTPTestCase to real code.
Now all the reader has to do is copy one of the "Hello, world"
examples to hello.py, copy the test example to test_hello.py, import
AsyncHTTPTestCase, and run the test. It's still not entirely seamless
and idiot-proof, but it's progress!
Of note: the example test can now actually assert things about the
response it receives.
Greg Ward [Sun, 21 Jun 2015 14:04:21 +0000 (10:04 -0400)]
Consistently format the three "Hello, world" examples (docs and README)
- encourage use of make_app() (makes testing easier)
- use fully-qualified module paths (painful in real-world code,
but makes examples clearer)
- don't define a main() function that is never called: just
use a boring old "__name__ == __main__" block, so the code
can be copy + pasted + executed immediately
- just use a tuple when defining routes, not url(...): this is
supposed to be a simple, minimalist example
Ben Darnell [Wed, 20 May 2015 01:46:21 +0000 (21:46 -0400)]
Disable twisted's test_process on python 3.
The new twisted 15.2.0 has some failures in this test that appear to be
interactions between the two package's test suites rather than a problem
in the integration itself, so just disable the tests for now.