[Pkg-privacy-commits] [txtorcon] 10/49: Hack around t.i.e.serverFromString() strangely not existing in py3k.
Ximin Luo
infinity0 at debian.org
Mon Oct 19 13:49:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository txtorcon.
commit 918ead02fd8ab76e240053d72c8cde39354af002
Author: Isis Lovecruft <isis at torproject.org>
Date: Thu May 21 05:10:08 2015 +0000
Hack around t.i.e.serverFromString() strangely not existing in py3k.
---
txtorcon/util.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/txtorcon/util.py b/txtorcon/util.py
index 75d94c8..ace0391 100644
--- a/txtorcon/util.py
+++ b/txtorcon/util.py
@@ -15,7 +15,13 @@ import struct
from twisted.internet import defer
from twisted.internet.interfaces import IProtocolFactory
-from twisted.internet.endpoints import serverFromString
+
+# FIXME: Remove this try/except block when t.i.e.serverFromString is available
+# in py3k. See also the related hack in :func:`available_tcp_port`.
+try:
+ from twisted.internet.endpoints import serverFromString
+except ImportError:
+ serverFromString = None
from zope.interface import implementer
@@ -283,7 +289,13 @@ def available_tcp_port(reactor):
assigned port number.
"""
- endpoint = serverFromString(reactor, 'tcp:0:interface=127.0.0.1')
+ # FIXME: Remove this if/else block when t.i.e.serverFromString is
+ # available in py3k.
+ if serverFromString:
+ endpoint = serverFromString(reactor, 'tcp:0:interface=127.0.0.1')
+ else:
+ endpoint = TCP4ServerEndpoint(reactor, 0, backlog=50, interface='127.0.0.1')
+
port = yield endpoint.listen(NoOpProtocolFactory())
address = port.getHost()
yield port.stopListening()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git
More information about the Pkg-privacy-commits
mailing list