Repository: tornadoweb/tornado
Pull request #2050 (2017-05-20 19:46:41)

build: Don't double-test on appveyor
Pointed out in #2028


Patch:
diff --git a/appveyor.yml b/appveyor.yml
index 412369c5..258a660b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -9,18 +9,22 @@ environment:
     - PYTHON: "C:\\Python35"
       PYTHON_VERSION: "3.5.x"
       PYTHON_ARCH: "32"
+      TOX_ENV: "py35"
 
     - PYTHON: "C:\\Python35-x64"
       PYTHON_VERSION: "3.5.x"
       PYTHON_ARCH: "64"
+      TOX_ENV: "py35"
 
     - PYTHON: "C:\\Python36"
       PYTHON_VERSION: "3.6.x"
       PYTHON_ARCH: "32"
+      TOX_ENV: "py36"
 
     - PYTHON: "C:\\Python36-x64"
       PYTHON_VERSION: "3.6.x"
       PYTHON_ARCH: "64"
+      TOX_ENV: "py36"
 
 install:
   # Make sure the right python version is first on the PATH.
@@ -44,7 +48,7 @@ test_script:
   # but for now it lets us avoid duplication with .travis.yml and tox.ini.
   # Running "py3x-full" would be nice but it's failing on installing
   # dependencies with no useful logs.
-  - "tox -e py35,py36 --skip-missing-interpreters"
+  - "tox -e %TOX_ENV%"
 
 after_test:
   # If tests are successful, create binary packages for the project.
diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py
index 554710ee..eef4a17a 100644
--- a/tornado/curl_httpclient.py
+++ b/tornado/curl_httpclient.py
@@ -74,12 +74,6 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
         self._multi.close()
         super(CurlAsyncHTTPClient, self).close()
 
-        # Set below properties to None to reduce the reference count of current
-        # instance, because those properties hold some methods of current
-        # instance that will case circular reference.
-        self._force_timeout_callback = None
-        self._multi = None
-
     def fetch_impl(self, request, callback):
         self._requests.append((request, callback))
         self._process_queue()
diff --git a/tornado/speedups.c b/tornado/speedups.c
index b714268a..c59bda00 100644
--- a/tornado/speedups.c
+++ b/tornado/speedups.c
@@ -1,12 +1,9 @@
 #define PY_SSIZE_T_CLEAN
 #include <Python.h>
-#include <stdint.h>
 
 static PyObject* websocket_mask(PyObject* self, PyObject* args) {
     const char* mask;
     Py_ssize_t mask_len;
-    uint32_t uint32_mask;
-    uint64_t uint64_mask;
     const char* data;
     Py_ssize_t data_len;
     Py_ssize_t i;
@@ -17,35 +14,13 @@ static PyObject* websocket_mask(PyObject* self, PyObject* args) {
         return NULL;
     }
 
-    uint32_mask = ((uint32_t*)mask)[0];
-
     result = PyBytes_FromStringAndSize(NULL, data_len);
     if (!result) {
         return NULL;
     }
     buf = PyBytes_AsString(result);
-
-    if (sizeof(size_t) >= 8) {
-        uint64_mask = uint32_mask;
-        uint64_mask = (uint64_mask << 32) | uint32_mask;
-
-        while (data_len >= 8) {
-            ((uint64_t*)buf)[0] = ((uint64_t*)data)[0] ^ uint64_mask;
-            data += 8;
-            buf += 8;
-            data_len -= 8;
-        }
-    }
-
-    while (data_len >= 4) {
-        ((uint32_t*)buf)[0] = ((uint32_t*)data)[0] ^ uint32_mask;
-        data += 4;
-        buf += 4;
-        data_len -= 4;
-    }
-
     for (i = 0; i < data_len; i++) {
-        buf[i] = data[i] ^ mask[i];
+        buf[i] = data[i] ^ mask[i % 4];
     }
 
     return result;
diff --git a/tornado/web.py b/tornado/web.py
index 132f42dd..d79889fa 100644
--- a/tornado/web.py
+++ b/tornado/web.py
@@ -319,7 +319,10 @@ class RequestHandler(object):
         if reason is not None:
             self._reason = escape.native_str(reason)
         else:
-            self._reason = httputil.responses.get(status_code, "Unknown")
+            try:
+                self._reason = httputil.responses[status_code]
+            except KeyError:
+                raise ValueError("unknown status code %d" % status_code)
 
     def get_status(self):
         """Returns the status code for our response."""
@@ -1558,7 +1561,11 @@ class RequestHandler(object):
             # send a response.
             return
         if isinstance(e, HTTPError):
-            self.send_error(e.status_code, exc_info=sys.exc_info())
+            if e.status_code not in httputil.responses and not e.reason:
+                gen_log.error("Bad HTTP status code: %d", e.status_code)
+                self.send_error(500, exc_info=sys.exc_info())
+            else:
+                self.send_error(e.status_code, exc_info=sys.exc_info())
         else:
             self.send_error(500, exc_info=sys.exc_info())
 


Test patch:
diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py
index de26c42e..d79ea52c 100644
--- a/tornado/test/web_test.py
+++ b/tornado/test/web_test.py
@@ -917,10 +917,6 @@ class ErrorResponseTest(WebTestCase):
             self.assertEqual(response.code, 503)
             self.assertTrue(b"503: Service Unavailable" in response.body)
 
-            response = self.fetch("/default?status=435")
-            self.assertEqual(response.code, 435)
-            self.assertTrue(b"435: Unknown" in response.body)
-
     def test_write_error(self):
         with ExpectLog(app_log, "Uncaught exception"):
             response = self.fetch("/write_error")
@@ -1493,9 +1489,9 @@ class StatusReasonTest(SimpleHandlerTestCase):
         response = self.fetch("/?code=682&reason=Bar")
         self.assertEqual(response.code, 682)
         self.assertEqual(response.reason, "Bar")
-        response = self.fetch("/?code=682")
-        self.assertEqual(response.code, 682)
-        self.assertEqual(response.reason, "Unknown")
+        with ExpectLog(app_log, 'Uncaught exception'):
+            response = self.fetch("/?code=682")
+        self.assertEqual(response.code, 500)
 
 
 @wsgi_safe