]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix unix socket test on linux. 1021/head
authorBen Darnell <ben@bendarnell.com>
Sun, 27 Apr 2014 16:58:40 +0000 (12:58 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 27 Apr 2014 16:58:40 +0000 (12:58 -0400)
Unix socket addresses are bytes on linux (but str on mac).  This mostly
works but causes errors in py3's -bb strict mode.

maint/vm/ubuntu12.04/tox.ini
tornado/httpserver.py

index 3a187f44866ad0a4414a62a174b45fbbd671030c..2a323eaa23466a5b5f75eb01e7cfca3c3f86db65 100644 (file)
@@ -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
index 4a82951162bf48a2a6d5580da7461c7da63c9ac4..597db20e46d97550999002a1c8511503f8e25373 100644 (file)
@@ -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)