Skip to content

Commit

Permalink
Merge branch 'master' into migrate_hazmat_issue_542
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrank63 committed Dec 13, 2018
2 parents df58b64 + 9799564 commit e7ddafd
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 133 deletions.
33 changes: 15 additions & 18 deletions .travis.yml
@@ -1,6 +1,5 @@
language: python
sudo: false
dist: trusty
dist: xenial

matrix:
include:
Expand All @@ -14,29 +13,27 @@ matrix:
env: PYPY_NIGHTLY_BRANCH=py3.5
- language: generic
env: PYPY_NIGHTLY_BRANCH=py3.6
# 3.5.0 and 3.5.1 have different __aiter__ semantics than all
# other versions, so we need to test them specially. Travis's
# xenial dist only provides 3.5.2+.
- python: 3.5.0
- python: 3.5.2
dist: trusty
- python: 3.5
- python: 3.6
- python: 3.7
dist: xenial
sudo: required
- python: 3.5-dev
- python: 3.6-dev
- python: 3.7-dev
dist: xenial
sudo: required
- python: 3.8-dev
dist: xenial
sudo: required
# - os: osx
# language: generic
# env: MACPYTHON=3.5.4
# - os: osx
# language: generic
# env: MACPYTHON=3.6.6
# - os: osx
# language: generic
# env: MACPYTHON=3.7.0
- os: osx
language: generic
env: MACPYTHON=3.5.4
- os: osx
language: generic
env: MACPYTHON=3.6.7
- os: osx
language: generic
env: MACPYTHON=3.7.1

script:
- ci/travis.sh
Expand Down
20 changes: 10 additions & 10 deletions ci/rtd-requirements.txt
Expand Up @@ -6,26 +6,26 @@
#
alabaster==0.7.12 # via sphinx
babel==2.6.0 # via sphinx
certifi==2018.10.15 # via requests
certifi==2018.11.29 # via requests
chardet==3.0.4 # via requests
click==7.0 # via towncrier
docutils==0.14 # via sphinx
idna==2.7 # via requests
idna==2.8 # via requests
imagesize==1.1.0 # via sphinx
incremental==17.5.0 # via towncrier
jinja2==2.10 # via sphinx, towncrier
markupsafe==1.0 # via jinja2
markupsafe==1.1.0 # via jinja2
packaging==18.0 # via sphinx
pygments==2.2.0 # via sphinx
pyparsing==2.2.2 # via packaging
pytz==2018.6 # via babel
requests==2.20.0 # via sphinx
six==1.11.0 # via packaging, sphinx
pygments==2.3.0 # via sphinx
pyparsing==2.3.0 # via packaging
pytz==2018.7 # via babel
requests==2.21.0 # via sphinx
six==1.12.0 # via packaging, sphinx
snowballstemmer==1.2.1 # via sphinx
sphinx-rtd-theme==0.4.2
sphinx==1.8.1
sphinx==1.8.2
sphinxcontrib-trio==1.0.1
sphinxcontrib-websupport==1.1.0 # via sphinx
toml==0.10.0 # via towncrier
towncrier==18.6.0
urllib3==1.24 # via requests
urllib3==1.24.1 # via requests
6 changes: 1 addition & 5 deletions docs/source/contributing.rst
Expand Up @@ -428,11 +428,7 @@ Short answer: whatever you feel comfortable with.

We do have one rule, which is the same one most F/OSS projects use:
don't merge your own PRs. We find that having another person look at
each PR leads to better quality. (Exception: you may see `@njsmith
<https://github.com/njsmith>`__ merging his own PRs. This happens
because he is lonely and has no-one to review them for him. It would
make him happy if you reviewed and – if they look good – merged his
PRs.)
each PR leads to better quality.

Beyond that, it all comes down to what you feel up to. If you don't
feel like you know enough to review a complex code change, then you
Expand Down
15 changes: 9 additions & 6 deletions docs/source/reference-core.rst
Expand Up @@ -876,12 +876,15 @@ Nursery objects provide the following interface:
This and :meth:`start` are the two fundamental methods for
creating concurrent tasks in trio.

Note that this is a synchronous function: it sets up the new
task, but then returns immediately, *before* it has a chance to
run. It won't actually run until some later point when you
execute a checkpoint and the scheduler decides to run it. If you
need to wait for the task to initialize itself before
continuing, see :meth:`start`.
Note that this is *not* an async function and you don't use await
when calling it. It sets up the new task, but then returns
immediately, *before* it has a chance to run. The new task won’t
actually get a chance to do anything until some later point when
you execute a checkpoint and the scheduler decides to run it.
If you want to run a function and immediately wait for its result,
then you don't need a nursery; just use ``await async_fn(*args)``.
If you want to wait for the task to initialize itself before
continuing, see :meth:`start()`.

It's possible to pass a nursery object into another task, which
allows that task to start new child tasks in the first task's
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/609.bugfix.rst
@@ -0,0 +1,2 @@
Fixed a race condition on macOS, where Trio's TCP listener would crash if an
incoming TCP connection was closed before the listener had a chance to accept it.
2 changes: 1 addition & 1 deletion test-requirements.in
Expand Up @@ -9,7 +9,7 @@ pylint # for pylint finding all symbols tests
jedi # for jedi code completion tests

# Tools
yapf == 0.24.0 # formatting
yapf ==0.25.0 # formatting
flake8

# https://github.com/python-trio/trio/pull/654#issuecomment-420518745
Expand Down
22 changes: 11 additions & 11 deletions test-requirements.txt
Expand Up @@ -5,18 +5,18 @@
# pip-compile --output-file test-requirements.txt test-requirements.in
#
asn1crypto==0.24.0 # via cryptography
astroid==2.0.4 # via pylint
astroid==2.1.0 # via pylint
atomicwrites==1.2.1 # via pytest
attrs==18.2.0 # via pytest
backcall==0.1.0 # via ipython
cffi==1.11.5 # via cryptography
coverage==4.5.1 # via pytest-cov
cryptography==2.3.1 # via pyopenssl, trustme
coverage==4.5.2 # via pytest-cov
cryptography==2.4.2 # via pyopenssl, trustme
decorator==4.3.0 # via ipython, traitlets
flake8==3.6.0
idna==2.7 # via cryptography, trustme
idna==2.8 # via cryptography, trustme
ipython-genutils==0.2.0 # via traitlets
ipython==7.1.1
ipython==7.2.0
isort==4.3.4 # via pylint
jedi==0.13.1
lazy-object-proxy==1.3.1 # via astroid
Expand All @@ -26,22 +26,22 @@ parso==0.3.1 # via jedi
pexpect==4.6.0 # via ipython
pickleshare==0.7.5 # via ipython
pluggy==0.8.0 # via pytest
prompt-toolkit==2.0.6 # via ipython
prompt-toolkit==2.0.7 # via ipython
ptyprocess==0.6.0 # via pexpect
py==1.7.0 # via pytest
pycodestyle==2.4.0 # via flake8
pycparser==2.19 # via cffi
pyflakes==2.0.0 # via flake8
pygments==2.2.0 # via ipython
pylint==2.1.1
pygments==2.3.0 # via ipython
pylint==2.2.2
pyopenssl==18.0.0
pytest-cov==2.6.0
pytest-faulthandler==1.5.0
pytest==3.9.3
six==1.11.0 # via astroid, cryptography, more-itertools, prompt-toolkit, pyopenssl, pytest, traitlets
pytest==4.0.1
six==1.12.0 # via astroid, cryptography, more-itertools, prompt-toolkit, pyopenssl, pytest, traitlets
traitlets==4.3.2 # via ipython
trustme==0.4.0
typed-ast==1.1.0 ; python_version < "3.7" and implementation_name == "cpython"
wcwidth==0.1.7 # via prompt-toolkit
wrapt==1.10.11 # via astroid
yapf==0.24.0
yapf==0.25.0
5 changes: 0 additions & 5 deletions trio/_highlevel_socket.py
Expand Up @@ -62,11 +62,6 @@ def __init__(self, socket):
raise TypeError("SocketStream requires trio socket object")
if socket.type != tsocket.SOCK_STREAM:
raise ValueError("SocketStream requires a SOCK_STREAM socket")
try:
socket.getpeername()
except OSError:
err = ValueError("SocketStream requires a connected socket")
raise err from None

self.socket = socket
self._send_conflict_detector = ConflictDetector(
Expand Down
47 changes: 0 additions & 47 deletions trio/_ssl.py
Expand Up @@ -159,53 +159,6 @@
from . import _sync
from ._util import ConflictDetector

__all__ = ["SSLStream", "SSLListener"]

################################################################
# Faking the stdlib ssl API
################################################################


def _reexport(name):
try:
value = getattr(_stdlib_ssl, name)
except AttributeError:
pass
else:
globals()[name] = value
__all__.append(name)


# Intentionally not re-exported:
# SSLContext
for _name in [
"SSLError",
"SSLZeroReturnError",
"SSLSyscallError",
"SSLEOFError",
"CertificateError",
"create_default_context",
"match_hostname",
"cert_time_to_seconds",
"DER_cert_to_PEM_cert",
"PEM_cert_to_DER_cert",
"get_default_verify_paths",
"Purpose",
"enum_certificates",
"enum_crls",
"SSLSession",
"VerifyMode",
"VerifyFlags",
"Options",
"AlertDescription",
"SSLErrorNumber",
]:
_reexport(_name)

for _name in _stdlib_ssl.__dict__.keys():
if _name == _name.upper():
_reexport(_name)

################################################################
# SSLStream
################################################################
Expand Down
14 changes: 3 additions & 11 deletions trio/_subprocess/linux_waitpid.py
@@ -1,11 +1,12 @@
import attr
import functools
import math
import os
import outcome
from typing import Any

from .. import _core
from .._sync import Event
from .._sync import CapacityLimiter, Event
from .._threads import run_sync_in_worker_thread


Expand All @@ -16,16 +17,7 @@ class WaitpidState:
outcome = attr.ib(default=None)


# https://github.com/python-trio/trio/issues/618
class StubLimiter:
def release_on_behalf_of(self, x):
pass

async def acquire_on_behalf_of(self, x):
pass


waitpid_limiter = StubLimiter()
waitpid_limiter = CapacityLimiter(math.inf)


# adapted from
Expand Down
95 changes: 93 additions & 2 deletions trio/ssl.py
Expand Up @@ -4,5 +4,96 @@
# temporaries, imports, etc. when implementing the module. So we put the
# implementation in an underscored module, and then re-export the public parts
# here.
from ._ssl import *
from ._ssl import __all__

# Trio-specific symbols:
from ._ssl import (SSLStream, SSLListener)

# Symbols re-exported from the stdlib ssl module:

# Always available
from ssl import (
cert_time_to_seconds, CertificateError, create_default_context,
DER_cert_to_PEM_cert, get_default_verify_paths, match_hostname,
PEM_cert_to_DER_cert, Purpose, SSLEOFError, SSLError, SSLSyscallError,
SSLZeroReturnError
)

# Added in python 3.6
try:
from ssl import AlertDescription, SSLErrorNumber, SSLSession, VerifyFlags, VerifyMode, Options
except ImportError:
pass

# Added in python 3.7
try:
from ssl import SSLCertVerificationError, TLSVersion
except ImportError:
pass

# Windows-only
try:
from ssl import enum_certificates, enum_crls
except ImportError:
pass

# Fake import to enable static analysis tools to catch the names
# (Real import is below)
try:
from ssl import (
AF_INET, ALERT_DESCRIPTION_ACCESS_DENIED,
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE,
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE,
ALERT_DESCRIPTION_BAD_CERTIFICATE, ALERT_DESCRIPTION_BAD_RECORD_MAC,
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED,
ALERT_DESCRIPTION_CERTIFICATE_REVOKED,
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN,
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE,
ALERT_DESCRIPTION_CLOSE_NOTIFY, ALERT_DESCRIPTION_DECODE_ERROR,
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE,
ALERT_DESCRIPTION_DECRYPT_ERROR, ALERT_DESCRIPTION_HANDSHAKE_FAILURE,
ALERT_DESCRIPTION_ILLEGAL_PARAMETER,
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY,
ALERT_DESCRIPTION_INTERNAL_ERROR, ALERT_DESCRIPTION_NO_RENEGOTIATION,
ALERT_DESCRIPTION_PROTOCOL_VERSION, ALERT_DESCRIPTION_RECORD_OVERFLOW,
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE, ALERT_DESCRIPTION_UNKNOWN_CA,
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY,
ALERT_DESCRIPTION_UNRECOGNIZED_NAME,
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE,
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION,
ALERT_DESCRIPTION_USER_CANCELLED, CERT_NONE, CERT_OPTIONAL,
CERT_REQUIRED, CHANNEL_BINDING_TYPES, HAS_ALPN, HAS_ECDH,
HAS_NEVER_CHECK_COMMON_NAME, HAS_NPN, HAS_SNI, OP_ALL,
OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION, OP_COOKIE_EXCHANGE,
OP_DONT_INSERT_EMPTY_FRAGMENTS, OP_EPHEMERAL_RSA,
OP_LEGACY_SERVER_CONNECT, OP_MICROSOFT_BIG_SSLV3_BUFFER,
OP_MICROSOFT_SESS_ID_BUG, OP_MSIE_SSLV2_RSA_PADDING,
OP_NETSCAPE_CA_DN_BUG, OP_NETSCAPE_CHALLENGE_BUG,
OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG,
OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG, OP_NO_QUERY_MTU, OP_PKCS1_CHECK_1,
OP_PKCS1_CHECK_2, OP_SSLEAY_080_CLIENT_DH_BUG,
OP_SSLREF2_REUSE_CERT_TYPE_BUG, OP_TLS_BLOCK_PADDING_BUG,
OP_TLS_D5_BUG, OP_TLS_ROLLBACK_BUG, SSL_ERROR_NONE,
SSL_ERROR_NO_SOCKET, OP_CIPHER_SERVER_PREFERENCE, OP_NO_COMPRESSION,
OP_NO_RENEGOTIATION, OP_NO_TICKET, OP_SINGLE_DH_USE,
OP_SINGLE_ECDH_USE, OPENSSL_VERSION_INFO, OPENSSL_VERSION_NUMBER,
OPENSSL_VERSION, PEM_FOOTER, PEM_HEADER, PROTOCOL_TLS_CLIENT,
PROTOCOL_TLS_SERVER, PROTOCOL_TLS, SO_TYPE, SOCK_STREAM, SOL_SOCKET,
SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE, SSL_ERROR_SSL,
SSL_ERROR_SYSCALL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_READ,
SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP,
SSL_ERROR_ZERO_RETURN, VERIFY_CRL_CHECK_CHAIN, VERIFY_CRL_CHECK_LEAF,
VERIFY_DEFAULT, VERIFY_X509_STRICT, VERIFY_X509_TRUSTED_FIRST
)
except ImportError:
pass

# Dynamically re-export whatever constants this particular Python happens to
# have:
import ssl as _stdlib_ssl
globals().update(
{
_name: getattr(_stdlib_ssl, _name)
for _name in _stdlib_ssl.__dict__.keys()
if _name.isupper() and not _name.startswith('_')
}
)
3 changes: 0 additions & 3 deletions trio/tests/test_exports.py
Expand Up @@ -49,9 +49,6 @@ def public_namespaces(module):

NAMESPACES = list(public_namespaces(trio))

# Not yet set up for static analysis:
NAMESPACES.remove("trio.ssl")


# pylint/jedi often have trouble with alpha releases, where Python's internals
# are in flux, grammar may not have settled down, etc.
Expand Down

0 comments on commit e7ddafd

Please sign in to comment.