diff --git a/netlib/certutils.py b/netlib/certutils.py index e1407936e..b3ba1dcfc 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -1,4 +1,4 @@ -import os, ssl, hashlib, socket, time, datetime, tempfile, shutil +import os, ssl, time, datetime, tempfile, shutil from pyasn1.type import univ, constraint, char, namedtype, tag from pyasn1.codec.der.decoder import decode from pyasn1.error import PyAsn1Error diff --git a/netlib/http.py b/netlib/http.py index 076baf873..29bcf43db 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -279,7 +279,7 @@ def read_response(rfile, method, body_size_limit): if line == "\r\n" or line == "\n": # Possible leftover from previous message line = rfile.readline() if not line: - raise HttpError(502, "Blank server response.") + raise HttpError(502, "Server disconnect.") parts = line.strip().split(" ", 2) if len(parts) == 2: # handle missing message gracefully parts.append("") diff --git a/netlib/tcp.py b/netlib/tcp.py index 556f97ac0..0a15d2ac8 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -139,7 +139,7 @@ class Reader(_FileLike): raise NetLibTimeout except socket.error: raise NetLibDisconnect - except SSL.SysCallError, v: + except SSL.SysCallError: raise NetLibDisconnect self.first_byte_timestamp = self.first_byte_timestamp or time.time() if not data: @@ -322,7 +322,7 @@ class BaseHandler: self.connection.shutdown() else: self.connection.shutdown(socket.SHUT_RDWR) - except (socket.error, SSL.Error), v: + except (socket.error, SSL.Error): # Socket probably already closed pass self.connection.close() diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 4fa2c5372..dffc2ace7 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -1,4 +1,4 @@ -import cStringIO, urllib, time, sys, traceback +import cStringIO, urllib, time, traceback import odict @@ -128,13 +128,13 @@ class WSGIAdaptor: write(i) if not state["headers_sent"]: write("") - except Exception, v: + except Exception: try: s = traceback.format_exc() errs.write(s) self.error_page(soc, state["headers_sent"], s) - except Exception, v: # pragma: no cover - pass # pragma: no cover + except Exception: # pragma: no cover + pass return errs.getvalue() diff --git a/test/test_http.py b/test/test_http.py index ed16fb4ae..666dfdbb0 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -222,7 +222,7 @@ def test_read_response(): r = cStringIO.StringIO(data) return http.read_response(r, method, limit) - tutils.raises("blank server response", tst, "", "GET", None) + tutils.raises("server disconnect", tst, "", "GET", None) tutils.raises("invalid server response", tst, "foo", "GET", None) data = """ HTTP/1.1 200 OK diff --git a/test/test_tcp.py b/test/test_tcp.py index f12a131b6..5b616969d 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -1,4 +1,4 @@ -import cStringIO, threading, Queue, time, socket +import cStringIO, Queue, time, socket from netlib import tcp, certutils, test import mock import tutils