Skip to content

Commit

Permalink
Merge branch 'trunk' into 8857-proto_helpers-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
tomprince committed Oct 12, 2016
2 parents ed09dd4 + e2f83ff commit a7a30b2
Show file tree
Hide file tree
Showing 36 changed files with 240 additions and 72 deletions.
22 changes: 19 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@ matrix:
# see: https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode7.1
python: 2.7
env: TOXENV=py27-alldeps-withcov-posix,codecov-publish
env: TOXENV=py27-alldeps-withcov-macos1010,codecov-publish
#
# OSX 10.11
#
- language: generic
os: osx
# 8 is OS X 10.11.x
# see: https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
osx_image: xcode8
env: TOXENV=py35-alldeps-withcov-macos,codecov-publish
- language: generic
os: osx
osx_image: xcode8
# Test cfreactor explicitly
env:
- TOXENV=py35-alldeps-withcov-macos,codecov-publish
- TWISTED_REACTOR=cf


allow_failures:
# For now, OSX run on Travis-CI has a few failures.
- os: osx
# twistedchecker job was introduce as an experimental job.
# Once it is stable we can enforce it
- env: TOXENV=txchecker-travis
Expand All @@ -75,6 +90,7 @@ addons:
cache:
directories:
- $HOME/.cache/pip
- $HOME/.pyenv


install:
Expand Down
14 changes: 14 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
python -m pip install --user virtualenv
python -m virtualenv ~/.venv
source ~/.venv/bin/activate

if [[ "${TOXENV}" == "py35-alldeps-withcov-macos,codecov-publish" ]]; then

brew update;
brew upgrade openssl;
brew install pyenv;
PYENV_ROOT="$HOME/.pyenv";
PATH="$PYENV_ROOT/bin:$PATH";
eval "$(pyenv init -)";
pyenv install -s 3.5.2;
pyenv global system 3.5.2;
pyenv rehash;

fi
fi

# Temporary workaround for https://github.com/pypa/setuptools/issues/776;
Expand Down
7 changes: 7 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ set -x
if [[ "$(uname -s)" == "Darwin" ]]; then
# Initialize the virtualenv created at install time.
source ~/.venv/bin/activate

if [[ "${TOXENV}" == "py35-alldeps-withcov-macos,codecov-publish" ]]; then
# Add pyenv path
PYENV_ROOT="$HOME/.pyenv";
PATH="$PYENV_ROOT/bin:$PATH";
eval "$(pyenv init -)";
fi
fi

tox -- $TOX_FLAGS
10 changes: 10 additions & 0 deletions docs/fun/Twisted.Quotes
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ glyph (~glyph@172.99.77.232) left the channel ("Textual IRC Client: www.textuala
<runciter> glyph: i feel like not checking certs was the most popular thing in the world in 2008
<runciter> it was like, 1) not checking cert validity 2) ruby on rails
%
<runciter> it appears that i've been banned from most servers
<@glyph> runciter: you probably joined too many channels from the same nick / IP
<runciter> glyph: yep :( since this currently in the "dumb hack" stage of development i figured my code would blow up first
<@glyph> runciter: that is a common problem with first-run Twisted services
<@glyph> runciter: it's more likely you'll knock over the service you're talking to than that you'll crash
<runciter> glyph: why does it have to work so well
<runciter> glyph: this was never a problem with gevent
%
<derwolfe> Twisted - thank you for continuing to be fun to use and relatively easy to test 😃
%
3 changes: 1 addition & 2 deletions src/twisted/conch/scripts/cftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def _getFilename(self, line):
else:
return ret[0], ret[1]

StdioClient.__dict__['cmd_?'] = StdioClient.cmd_HELP
setattr(StdioClient, 'cmd_?', StdioClient.cmd_HELP)

class SSHConnection(connection.SSHConnection):
def serviceStarted(self):
Expand Down Expand Up @@ -928,4 +928,3 @@ def startWriting(self):

if __name__ == '__main__':
run()

3 changes: 3 additions & 0 deletions src/twisted/internet/_sslverify.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
SSL_CB_HANDSHAKE_DONE = 0x20

from twisted.python import log
from twisted.python._oldstyle import _oldStyle


def _cantSetHostnameIndication(connection, hostname):
Expand Down Expand Up @@ -415,6 +416,7 @@ def uniqueValues(mapping):



@_oldStyle
class CertBase:
"""
Base class for public (certificate only) and private (certificate + key
Expand Down Expand Up @@ -759,6 +761,7 @@ def signRequestObject(self, certificateRequest, serialNumber,
digestAlgorithm)


@_oldStyle
class PublicKey:
"""
A L{PublicKey} is a representation of the public part of a key pair.
Expand Down
4 changes: 4 additions & 0 deletions src/twisted/internet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
from twisted.python.compat import unicode, iteritems
from twisted.python.runtime import seconds as runtimeSeconds, platform
from twisted.internet.defer import Deferred, DeferredList
from twisted.python._oldstyle import _oldStyle

# This import is for side-effects! Even if you don't see any code using it
# in this module, don't delete it.
from twisted.python import threadable


@implementer(IDelayedCall)
@_oldStyle
class DelayedCall:

# enable .debug to record creator call stack, and it will be logged if
Expand Down Expand Up @@ -279,6 +281,7 @@ def getHostByName(self, name, timeout = (1, 3, 11, 45)):


@implementer(IResolverSimple)
@_oldStyle
class BlockingResolver:

def getHostByName(self, name, timeout = (1, 3, 11, 45)):
Expand Down Expand Up @@ -1016,6 +1019,7 @@ def callFromThread(self, f, *args, **kw):


@implementer(IConnector)
@_oldStyle
class BaseConnector:
"""Basic implementation of connector.
Expand Down
62 changes: 32 additions & 30 deletions src/twisted/internet/cfreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,36 +167,40 @@ def _socketCallback(self, cfSocket, callbackType,
)
return

why = None
isRead = False
src, skt, readWriteDescriptor, rw = self._fdmap[fd]
try:
if readWriteDescriptor.fileno() == -1:
why = _NO_FILEDESC
else:
isRead = callbackType == kCFSocketReadCallBack
# CFSocket seems to deliver duplicate read/write notifications
# sometimes, especially a duplicate writability notification
# when first registering the socket. This bears further
# investigation, since I may have been mis-interpreting the
# behavior I was seeing. (Running the full Twisted test suite,
# while thorough, is not always entirely clear.) Until this has
# been more thoroughly investigated , we consult our own
# reading/writing state flags to determine whether we should
# actually attempt a doRead/doWrite first. -glyph
if isRead:
if rw[_READ]:
why = log.callWithLogger(
readWriteDescriptor, readWriteDescriptor.doRead)

def _drdw():
why = None
isRead = False

try:
if readWriteDescriptor.fileno() == -1:
why = _NO_FILEDESC
else:
if rw[_WRITE]:
why = log.callWithLogger(
readWriteDescriptor, readWriteDescriptor.doWrite)
except:
why = sys.exc_info()[1]
log.err()
if why:
self._disconnectSelectable(readWriteDescriptor, why, isRead)
isRead = callbackType == kCFSocketReadCallBack
# CFSocket seems to deliver duplicate read/write
# notifications sometimes, especially a duplicate
# writability notification when first registering the
# socket. This bears further investigation, since I may
# have been mis-interpreting the behavior I was seeing.
# (Running the full Twisted test suite, while thorough, is
# not always entirely clear.) Until this has been more
# thoroughly investigated , we consult our own
# reading/writing state flags to determine whether we
# should actually attempt a doRead/doWrite first. -glyph
if isRead:
if rw[_READ]:
why = readWriteDescriptor.doRead()
else:
if rw[_WRITE]:
why = readWriteDescriptor.doWrite()
except:
why = sys.exc_info()[1]
log.err()
if why:
self._disconnectSelectable(readWriteDescriptor, why, isRead)

log.callWithLogger(readWriteDescriptor, _drdw)


def _watchFD(self, fd, descr, flag):
Expand Down Expand Up @@ -496,5 +500,3 @@ def install(runLoop=None, runner=None):
from twisted.internet.main import installReactor
installReactor(reactor)
return reactor


7 changes: 5 additions & 2 deletions src/twisted/internet/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import warnings
from sys import exc_info
from functools import wraps
from incremental import Version

# Twisted imports
from twisted.python.compat import cmp, comparable
from twisted.python import lockfile, failure
from twisted.logger import Logger
from twisted.python.deprecate import warnAboutFunction, deprecated
from incremental import Version
from twisted.python._oldstyle import _oldStyle

log = Logger()

Expand Down Expand Up @@ -193,6 +194,7 @@ def getDebugging():



@_oldStyle
class Deferred:
"""
This is a callback which will be put off until later.
Expand Down Expand Up @@ -795,6 +797,7 @@ def main(reactor):



@_oldStyle
class DebugInfo:
"""
Deferred debug helper.
Expand Down Expand Up @@ -1067,7 +1070,7 @@ def gatherResults(deferredList, consumeErrors=False):


## deferredGenerator

@_oldStyle
class waitForDeferred:
"""
See L{deferredGenerator}.
Expand Down
6 changes: 6 additions & 0 deletions src/twisted/internet/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
from twisted.python import log, failure, components
from twisted.internet import interfaces, error, defer
from twisted.logger import _loggerFor
from twisted.python._oldstyle import _oldStyle


@implementer(interfaces.IProtocolFactory, interfaces.ILoggingContext)
@_oldStyle
class Factory:
"""
This is a factory which produces protocols.
Expand Down Expand Up @@ -221,6 +223,7 @@ def fire(self, func, value):



@_oldStyle
class ClientCreator:
"""
Client connections that do not require a factory.
Expand Down Expand Up @@ -468,6 +471,7 @@ class ServerFactory(Factory):



@_oldStyle
class BaseProtocol:
"""
This is the abstract superclass of all protocols.
Expand Down Expand Up @@ -659,6 +663,7 @@ def processEnded(self, reason):



@_oldStyle
class AbstractDatagramProtocol:
"""
Abstract protocol for datagram-oriented transports, e.g. IP, ICMP, ARP, UDP.
Expand Down Expand Up @@ -775,6 +780,7 @@ def connectionFailed(self, failure):


@implementer(interfaces.ITransport)
@_oldStyle
class FileWrapper:
"""A wrapper around a file-like object to make it behave as a Transport.
Expand Down
2 changes: 2 additions & 0 deletions src/twisted/internet/serialport.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
from serial import STOPBITS_ONE, STOPBITS_TWO
from serial import FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS

from twisted.python._oldstyle import _oldStyle
from twisted.python.runtime import platform



@_oldStyle
class BaseSerialPort:
"""
Base class for Windows and POSIX serial ports.
Expand Down
4 changes: 3 additions & 1 deletion src/twisted/internet/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@

# Twisted imports
from twisted.internet import tcp, interfaces

from twisted.python._oldstyle import _oldStyle


@implementer(interfaces.IOpenSSLContextFactory)
@_oldStyle
class ContextFactory:
"""A factory for SSL context objects, for server SSL connections."""

Expand Down Expand Up @@ -137,6 +138,7 @@ def getContext(self):


@implementer(interfaces.IOpenSSLContextFactory)
@_oldStyle
class ClientContextFactory:
"""A context factory for SSL clients."""

Expand Down
2 changes: 1 addition & 1 deletion src/twisted/internet/test/connectionmixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def connectionLost(self, reason):



class EndpointCreator:
class EndpointCreator(object):
"""
Create client and server endpoints that know how to connect to each other.
"""
Expand Down
2 changes: 2 additions & 0 deletions src/twisted/internet/test/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ class PTYProcessTestsBuilder(ProcessTestsBuilderBase):
if platform.isWindows():
skip = "PTYs are not supported on Windows."
elif platform.isMacOSX():
skip = "PTYs are flaky from a Darwin bug. See #8840."

skippedReactors = {
"twisted.internet.pollreactor.PollReactor":
"OS X's poll() does not support PTYs"}
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/internet/test/test_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@



class UNIXFamilyMixin:
class UNIXFamilyMixin(object):
"""
Test-helper defining mixin for things related to AF_UNIX sockets.
"""
Expand Down
Loading

0 comments on commit a7a30b2

Please sign in to comment.