From: Ben Darnell Date: Sun, 27 Apr 2014 16:58:40 +0000 (-0400) Subject: Fix unix socket test on linux. X-Git-Tag: v4.0.0b1~91^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1021%2Fhead;p=thirdparty%2Ftornado.git Fix unix socket test on linux. Unix socket addresses are bytes on linux (but str on mac). This mostly works but causes errors in py3's -bb strict mode. --- diff --git a/maint/vm/ubuntu12.04/tox.ini b/maint/vm/ubuntu12.04/tox.ini index 3a187f448..2a323eaa2 100644 --- a/maint/vm/ubuntu12.04/tox.ini +++ b/maint/vm/ubuntu12.04/tox.ini @@ -28,3 +28,7 @@ deps = pycurl twisted==12.2.0 commands = python -m tornado.test.runtests --ioloop=tornado.platform.twisted.TwistedIOLoop {posargs:} + +[testenv:py32] +basepython = python3.2 +commands = python -bb -m tornado.test.runtests {posargs:} \ No newline at end of file diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 4a8295116..597db20e4 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -30,6 +30,7 @@ from __future__ import absolute_import, division, print_function, with_statement import socket +from tornado.escape import native_str from tornado.http1connection import HTTP1ServerConnection, HTTP1ConnectionParameters from tornado import gen from tornado import httputil @@ -207,6 +208,11 @@ class _HTTPRequestContext(object): def __str__(self): if self.address_family in (socket.AF_INET, socket.AF_INET6): return self.remote_ip + elif isinstance(self.address, bytes): + # Python 3 with the -bb option warns about str(bytes), + # so convert it explicitly. + # Unix socket addresses are str on mac but bytes on linux. + return native_str(self.address) else: return str(self.address)