diff --git a/docs/source/conf.py b/docs/source/conf.py index 8c94eb136..f000c2dba 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Gunicorn documentation build configuration file # diff --git a/examples/alt_spec.py b/examples/alt_spec.py index d5c682f1d..9a7e7c8cf 100644 --- a/examples/alt_spec.py +++ b/examples/alt_spec.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # An example of how to pass information from the command line to # a WSGI app. Only applies to the native WSGI workers used by diff --git a/examples/boot_fail.py b/examples/boot_fail.py index 0a2455ed6..c4f80f984 100644 --- a/examples/boot_fail.py +++ b/examples/boot_fail.py @@ -1,4 +1,3 @@ - raise RuntimeError("Bad app!") def app(environ, start_response): diff --git a/examples/deep/test.py b/examples/deep/test.py index 09ea06f08..dd5f8f693 100644 --- a/examples/deep/test.py +++ b/examples/deep/test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/echo.py b/examples/echo.py index e10332d87..b03a72f3c 100644 --- a/examples/echo.py +++ b/examples/echo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/frameworks/cherryapp.py b/examples/frameworks/cherryapp.py index 5b97ce0bc..fa9ea676a 100644 --- a/examples/frameworks/cherryapp.py +++ b/examples/frameworks/cherryapp.py @@ -1,7 +1,7 @@ import cherrypy -class Root(object): +class Root: @cherrypy.expose def index(self): return 'Hello World!' diff --git a/examples/frameworks/django/testing/testing/apps/someapp/middleware.py b/examples/frameworks/django/testing/testing/apps/someapp/middleware.py index ddc667a90..74d10c34a 100644 --- a/examples/frameworks/django/testing/testing/apps/someapp/middleware.py +++ b/examples/frameworks/django/testing/testing/apps/someapp/middleware.py @@ -8,7 +8,7 @@ def child_process(queue): requests.get('http://requestb.in/15s95oz1') -class GunicornSubProcessTestMiddleware(object): +class GunicornSubProcessTestMiddleware: def __init__(self): super().__init__() self.queue = Queue() diff --git a/examples/frameworks/tornadoapp.py b/examples/frameworks/tornadoapp.py index 0b5a6f94a..0285fcd5c 100644 --- a/examples/frameworks/tornadoapp.py +++ b/examples/frameworks/tornadoapp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/longpoll.py b/examples/longpoll.py index 5b5d8c96b..4b453d496 100644 --- a/examples/longpoll.py +++ b/examples/longpoll.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -7,7 +6,7 @@ import sys import time -class TestIter(object): +class TestIter: def __iter__(self): lines = [b'line 1\n', b'line 2\n'] diff --git a/examples/multiapp.py b/examples/multiapp.py index c88885864..04edf08f0 100644 --- a/examples/multiapp.py +++ b/examples/multiapp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -25,7 +24,7 @@ from test import app as app2 -class Application(object): +class Application: def __init__(self): self.map = Mapper() self.map.connect('app1', '/app1url', app=app1) diff --git a/examples/multidomainapp.py b/examples/multidomainapp.py index 25727badd..9d441a95f 100644 --- a/examples/multidomainapp.py +++ b/examples/multidomainapp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/readline_app.py b/examples/readline_app.py index 4a87851bb..e72b90eb4 100644 --- a/examples/readline_app.py +++ b/examples/readline_app.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/sendfile.py b/examples/sendfile.py index d8489d9b8..7060ecda5 100644 --- a/examples/sendfile.py +++ b/examples/sendfile.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/slowclient.py b/examples/slowclient.py index 72041f86b..1eb582d04 100644 --- a/examples/slowclient.py +++ b/examples/slowclient.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/standalone_app.py b/examples/standalone_app.py index 7731aaf53..d4ec7caf4 100644 --- a/examples/standalone_app.py +++ b/examples/standalone_app.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- # # An example of a standalone application using the internal API of Gunicorn. # diff --git a/examples/test.py b/examples/test.py index 09ea06f08..dd5f8f693 100644 --- a/examples/test.py +++ b/examples/test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/timeout.py b/examples/timeout.py index 2e661b2bb..b6ca2b50d 100644 --- a/examples/timeout.py +++ b/examples/timeout.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/examples/websocket/gevent_websocket.py b/examples/websocket/gevent_websocket.py index c5855d4e2..ff5109e52 100644 --- a/examples/websocket/gevent_websocket.py +++ b/examples/websocket/gevent_websocket.py @@ -1,4 +1,3 @@ - import collections import errno import re @@ -17,7 +16,7 @@ WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -class WebSocketWSGI(object): +class WebSocketWSGI: def __init__(self, handler): self.handler = handler @@ -118,7 +117,7 @@ def __call__(self, environ, start_response): # doesn't barf on the fact that we didn't call start_response return ALREADY_HANDLED -class WebSocket(object): +class WebSocket: """A websocket object that handles the details of serialization/deserialization to the socket. diff --git a/examples/websocket/websocket.py b/examples/websocket/websocket.py index 63f709aeb..0e8dffeb5 100644 --- a/examples/websocket/websocket.py +++ b/examples/websocket/websocket.py @@ -1,4 +1,3 @@ - import collections import errno import re @@ -18,7 +17,7 @@ WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -class WebSocketWSGI(object): +class WebSocketWSGI: def __init__(self, handler): self.handler = handler @@ -119,7 +118,7 @@ def __call__(self, environ, start_response): # doesn't barf on the fact that we didn't call start_response return ALREADY_HANDLED -class WebSocket(object): +class WebSocket: """A websocket object that handles the details of serialization/deserialization to the socket. diff --git a/examples/when_ready.conf.py b/examples/when_ready.conf.py index 1531ec14a..dc8480ef6 100644 --- a/examples/when_ready.conf.py +++ b/examples/when_ready.conf.py @@ -17,7 +17,7 @@ def __init__(self, server, max_mem): def memory_usage(self, pid): try: out = commands.getoutput("ps -o rss -p %s" % pid) - except IOError: + except OSError: return -1 used_mem = sum(int(x) for x in out.split('\n')[1:]) return used_mem diff --git a/gunicorn/__init__.py b/gunicorn/__init__.py index 5d3c2030d..cdcd1352e 100644 --- a/gunicorn/__init__.py +++ b/gunicorn/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/__main__.py b/gunicorn/__main__.py index fda831570..ceb44d086 100644 --- a/gunicorn/__main__.py +++ b/gunicorn/__main__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/app/__init__.py b/gunicorn/app/__init__.py index 87f06117b..530e35ca4 100644 --- a/gunicorn/app/__init__.py +++ b/gunicorn/app/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/app/base.py b/gunicorn/app/base.py index dbd05bc7f..9bf7a4f0f 100644 --- a/gunicorn/app/base.py +++ b/gunicorn/app/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -14,7 +13,7 @@ from gunicorn import debug -class BaseApplication(object): +class BaseApplication: """ An application interface for configuring and loading the various necessities for any given web framework. diff --git a/gunicorn/app/pasterapp.py b/gunicorn/app/pasterapp.py index 4c9fc7def..b1738f250 100644 --- a/gunicorn/app/pasterapp.py +++ b/gunicorn/app/pasterapp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/app/wsgiapp.py b/gunicorn/app/wsgiapp.py index 4e0031234..1b0ba969d 100644 --- a/gunicorn/app/wsgiapp.py +++ b/gunicorn/app/wsgiapp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 1cf436748..e84dd02f8 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -18,7 +17,7 @@ from gunicorn import __version__, SERVER_SOFTWARE -class Arbiter(object): +class Arbiter: """ Arbiter maintain the workers processes alive. It launches or kills them if needed. It also manages application reloading @@ -333,7 +332,7 @@ def wakeup(self): """ try: os.write(self.PIPE[1], b'.') - except IOError as e: + except OSError as e: if e.errno not in [errno.EAGAIN, errno.EINTR]: raise @@ -362,7 +361,7 @@ def sleep(self): return while os.read(self.PIPE[0], 1): pass - except (select.error, OSError) as e: + except OSError as e: # TODO: select.error is a subclass of OSError since Python 3.3. error_number = getattr(e, 'errno', e.args[0]) if error_number not in [errno.EAGAIN, errno.EINTR]: diff --git a/gunicorn/config.py b/gunicorn/config.py index 2376a765c..402a26b68 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -44,7 +43,7 @@ def auto_int(_, x): return int(x, 0) -class Config(object): +class Config: def __init__(self, usage=None, prog=None): self.settings = make_settings() @@ -256,7 +255,7 @@ def fmt_desc(cls, desc): setattr(cls, "short", desc.splitlines()[0]) -class Setting(object): +class Setting: name = None value = None section = None diff --git a/gunicorn/debug.py b/gunicorn/debug.py index a492df9e4..5fae0b4dd 100644 --- a/gunicorn/debug.py +++ b/gunicorn/debug.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -16,7 +15,7 @@ _token_spliter = re.compile(r'\W+') -class Spew(object): +class Spew: def __init__(self, trace_names=None, show_values=True): self.trace_names = trace_names @@ -37,7 +36,7 @@ def __call__(self, frame, event, arg): try: src = inspect.getsourcelines(frame) line = src[lineno] - except IOError: + except OSError: line = 'Unknown code named [%s]. VM instruction #%d' % ( frame.f_code.co_name, frame.f_lasti) if self.trace_names is None or name in self.trace_names: diff --git a/gunicorn/errors.py b/gunicorn/errors.py index 727d336ad..112838080 100644 --- a/gunicorn/errors.py +++ b/gunicorn/errors.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index b552e26a8..e34fcd5f7 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -162,7 +161,7 @@ def parse_syslog_address(addr): return (socktype, (host, port)) -class Logger(object): +class Logger: LOG_LEVELS = { "critical": logging.CRITICAL, diff --git a/gunicorn/http/__init__.py b/gunicorn/http/__init__.py index 1da6f3ec1..11473bb0a 100644 --- a/gunicorn/http/__init__.py +++ b/gunicorn/http/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/http/body.py b/gunicorn/http/body.py index 318808bcf..d7ee29e78 100644 --- a/gunicorn/http/body.py +++ b/gunicorn/http/body.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -10,7 +9,7 @@ InvalidChunkSize) -class ChunkedReader(object): +class ChunkedReader: def __init__(self, req, unreader): self.req = req self.parser = self.parse_chunked(unreader) @@ -113,7 +112,7 @@ def get_data(self, unreader, buf): buf.write(data) -class LengthReader(object): +class LengthReader: def __init__(self, unreader, length): self.unreader = unreader self.length = length @@ -143,7 +142,7 @@ def read(self, size): return ret -class EOFReader(object): +class EOFReader: def __init__(self, unreader): self.unreader = unreader self.buf = io.BytesIO() @@ -181,7 +180,7 @@ def read(self, size): return ret -class Body(object): +class Body: def __init__(self, reader): self.reader = reader self.buf = io.BytesIO() diff --git a/gunicorn/http/errors.py b/gunicorn/http/errors.py index 861dcb4f8..bcb970072 100644 --- a/gunicorn/http/errors.py +++ b/gunicorn/http/errors.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py index 7480baa7c..59ce0bf4b 100644 --- a/gunicorn/http/message.py +++ b/gunicorn/http/message.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -31,7 +30,7 @@ RFC9110_5_5_INVALID_AND_DANGEROUS = re.compile(r"[\0\r\n]") -class Message(object): +class Message: def __init__(self, cfg, unreader, peer_addr): self.cfg = cfg self.unreader = unreader @@ -376,13 +375,13 @@ def parse_proxy_protocol(self, line): try: socket.inet_pton(socket.AF_INET, s_addr) socket.inet_pton(socket.AF_INET, d_addr) - except socket.error: + except OSError: raise InvalidProxyLine(line) elif proto == "TCP6": try: socket.inet_pton(socket.AF_INET6, s_addr) socket.inet_pton(socket.AF_INET6, d_addr) - except socket.error: + except OSError: raise InvalidProxyLine(line) try: diff --git a/gunicorn/http/parser.py b/gunicorn/http/parser.py index 5d689f06a..88da17ab0 100644 --- a/gunicorn/http/parser.py +++ b/gunicorn/http/parser.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -7,7 +6,7 @@ from gunicorn.http.unreader import SocketUnreader, IterUnreader -class Parser(object): +class Parser: mesg_class = None diff --git a/gunicorn/http/unreader.py b/gunicorn/http/unreader.py index 273bfc311..9aadfbcff 100644 --- a/gunicorn/http/unreader.py +++ b/gunicorn/http/unreader.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -10,7 +9,7 @@ # a given type of data source. -class Unreader(object): +class Unreader: def __init__(self): self.buf = io.BytesIO() diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 6f3d9b68f..419ac503a 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -25,7 +24,7 @@ log = logging.getLogger(__name__) -class FileWrapper(object): +class FileWrapper: def __init__(self, filelike, blksize=8192): self.filelike = filelike @@ -198,7 +197,7 @@ def create(req, sock, client, server, cfg): return resp, environ -class Response(object): +class Response: def __init__(self, req, sock, cfg): self.req = req diff --git a/gunicorn/instrument/statsd.py b/gunicorn/instrument/statsd.py index ad5bb0a90..7bc4e6ffd 100644 --- a/gunicorn/instrument/statsd.py +++ b/gunicorn/instrument/statsd.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/pidfile.py b/gunicorn/pidfile.py index 585b02af7..b171f7d91 100644 --- a/gunicorn/pidfile.py +++ b/gunicorn/pidfile.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -8,7 +7,7 @@ import tempfile -class Pidfile(object): +class Pidfile: """\ Manage a PID file. If a specific name is provided it and '"%s.oldpid" % name' will be used. Otherwise @@ -52,7 +51,7 @@ def rename(self, path): def unlink(self): """ delete pidfile""" try: - with open(self.fname, "r") as f: + with open(self.fname) as f: pid1 = int(f.read() or 0) if pid1 == self.pid: @@ -65,7 +64,7 @@ def validate(self): if not self.fname: return try: - with open(self.fname, "r") as f: + with open(self.fname) as f: try: wpid = int(f.read()) except ValueError: @@ -80,7 +79,7 @@ def validate(self): if e.args[0] == errno.ESRCH: return raise - except IOError as e: + except OSError as e: if e.args[0] == errno.ENOENT: return raise diff --git a/gunicorn/reloader.py b/gunicorn/reloader.py index 88b540bdb..1c67f2a7d 100644 --- a/gunicorn/reloader.py +++ b/gunicorn/reloader.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -117,7 +116,7 @@ def run(self): else: - class InotifyReloader(object): + class InotifyReloader: def __init__(self, extra_files=None, callback=None): raise ImportError('You must have the inotify module installed to ' 'use the inotify reloader') diff --git a/gunicorn/sock.py b/gunicorn/sock.py index d8aa9f83e..eb2b6fa9c 100644 --- a/gunicorn/sock.py +++ b/gunicorn/sock.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -14,7 +13,7 @@ from gunicorn import util -class BaseSocket(object): +class BaseSocket: def __init__(self, address, conf, log, fd=None): self.log = log @@ -43,7 +42,7 @@ def set_options(self, sock, bound=False): and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) - except socket.error as err: + except OSError as err: if err.errno not in (errno.ENOPROTOOPT, errno.EINVAL): raise if not bound: @@ -66,7 +65,7 @@ def close(self): try: self.sock.close() - except socket.error as e: + except OSError as e: self.log.info("Error while closing socket %s", str(e)) self.sock = None @@ -183,7 +182,7 @@ def create_sockets(conf, log, fds=None): for i in range(5): try: sock = sock_type(addr, conf, log) - except socket.error as e: + except OSError as e: if e.args[0] == errno.EADDRINUSE: log.error("Connection in use: %s", str(addr)) if e.args[0] == errno.EADDRNOTAVAIL: diff --git a/gunicorn/systemd.py b/gunicorn/systemd.py index 5bc1a7449..9b1855060 100644 --- a/gunicorn/systemd.py +++ b/gunicorn/systemd.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/util.py b/gunicorn/util.py index 751deea71..ecd817472 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -217,7 +216,7 @@ def unlink(filename): def is_ipv6(addr): try: socket.inet_pton(socket.AF_INET6, addr) - except socket.error: # not a valid address + except OSError: # not a valid address return False except ValueError: # ipv6 not supported on this platform return False @@ -269,7 +268,7 @@ def set_non_blocking(fd): def close(sock): try: sock.close() - except socket.error: + except OSError: pass @@ -566,7 +565,7 @@ def check_is_writable(path): try: with open(path, 'a') as f: f.close() - except IOError as e: + except OSError as e: raise RuntimeError("Error: '%s' isn't writable [%r]" % (path, e)) @@ -587,7 +586,7 @@ def has_fileno(obj): # check BytesIO case and maybe others try: obj.fileno() - except (AttributeError, IOError, io.UnsupportedOperation): + except (AttributeError, OSError, io.UnsupportedOperation): return False return True diff --git a/gunicorn/workers/__init__.py b/gunicorn/workers/__init__.py index ae753e1cd..3da5f85e8 100644 --- a/gunicorn/workers/__init__.py +++ b/gunicorn/workers/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index bf0ce32ca..93c465c98 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -28,7 +27,7 @@ from gunicorn.workers.workertmp import WorkerTmp -class Worker(object): +class Worker: SIGNALS = [getattr(signal, "SIG%s" % x) for x in ( "ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split() diff --git a/gunicorn/workers/base_async.py b/gunicorn/workers/base_async.py index 6a79d7ed0..9466d6aaa 100644 --- a/gunicorn/workers/base_async.py +++ b/gunicorn/workers/base_async.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -60,7 +59,7 @@ def handle(self, listener, client, addr): except ssl.SSLError: # pass to next try-except level util.reraise(*sys.exc_info()) - except EnvironmentError: + except OSError: # pass to next try-except level util.reraise(*sys.exc_info()) except Exception as e: @@ -72,7 +71,7 @@ def handle(self, listener, client, addr): else: self.log.debug("Error processing SSL request.") self.handle_error(req, client, addr, e) - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN): self.log.exception("Socket error processing request.") else: @@ -124,7 +123,7 @@ def handle_request(self, listener_name, req, sock, addr): raise StopIteration() except StopIteration: raise - except EnvironmentError: + except OSError: # If the original exception was a socket.error we delegate # handling it to the caller (where handle() might ignore it) util.reraise(*sys.exc_info()) @@ -136,7 +135,7 @@ def handle_request(self, listener_name, req, sock, addr): try: sock.shutdown(socket.SHUT_RDWR) sock.close() - except EnvironmentError: + except OSError: pass raise StopIteration() raise diff --git a/gunicorn/workers/geventlet.py b/gunicorn/workers/geventlet.py index c42ed1186..087eb61ec 100644 --- a/gunicorn/workers/geventlet.py +++ b/gunicorn/workers/geventlet.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index cad021c43..b9b9b4408 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -147,7 +146,7 @@ def init_process(self): super().init_process() -class GeventResponse(object): +class GeventResponse: status = None headers = None diff --git a/gunicorn/workers/gthread.py b/gunicorn/workers/gthread.py index c9c42345f..7a23228cd 100644 --- a/gunicorn/workers/gthread.py +++ b/gunicorn/workers/gthread.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -31,7 +30,7 @@ from ..http import wsgi -class TConn(object): +class TConn: def __init__(self, cfg, sock, client, server): self.cfg = cfg @@ -128,7 +127,7 @@ def accept(self, server, listener): with self._lock: self.poller.register(conn.sock, selectors.EVENT_READ, partial(self.on_client_socket_readable, conn)) - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, errno.EWOULDBLOCK): raise @@ -171,7 +170,7 @@ def murder_keepalived(self): with self._lock: try: self.poller.unregister(conn.sock) - except EnvironmentError as e: + except OSError as e: if e.errno != errno.EBADF: raise except KeyError: @@ -295,7 +294,7 @@ def handle(self, conn): self.log.debug("Error processing SSL request.") self.handle_error(req, conn.sock, conn.client, e) - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN): self.log.exception("Socket error processing request.") else: @@ -349,7 +348,7 @@ def handle_request(self, req, conn): if resp.should_close(): self.log.debug("Closing connection.") return False - except EnvironmentError: + except OSError: # pass to next try-except level util.reraise(*sys.exc_info()) except Exception: @@ -360,7 +359,7 @@ def handle_request(self, req, conn): try: conn.sock.shutdown(socket.SHUT_RDWR) conn.sock.close() - except EnvironmentError: + except OSError: pass raise StopIteration() raise diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py index 285061196..544af7d09 100644 --- a/gunicorn/workers/gtornado.py +++ b/gunicorn/workers/gtornado.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -135,7 +134,7 @@ class _HTTPServer(tornado.httpserver.HTTPServer): def on_close(instance, server_conn): self.handle_request() - super(_HTTPServer, instance).on_close(server_conn) + super().on_close(server_conn) server_class = _HTTPServer diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index ddcd77270..4c029f912 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -40,7 +39,7 @@ def wait(self, timeout): os.read(self.PIPE[0], 1) return ret[0] - except select.error as e: + except OSError as e: if e.args[0] == errno.EINTR: return self.sockets if e.args[0] == errno.EBADF: @@ -73,7 +72,7 @@ def run_for_one(self, timeout): # process. continue - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, errno.EWOULDBLOCK): raise @@ -102,7 +101,7 @@ def run_for_multiple(self, timeout): try: self.accept(listener) - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, errno.EWOULDBLOCK): raise @@ -144,7 +143,7 @@ def handle(self, listener, client, addr): else: self.log.debug("Error processing SSL request.") self.handle_error(req, client, addr, e) - except EnvironmentError as e: + except OSError as e: if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN): self.log.exception("Socket error processing request.") else: @@ -188,7 +187,7 @@ def handle_request(self, listener, req, client, addr): self.log.access(resp, req, environ, request_time) if hasattr(respiter, "close"): respiter.close() - except EnvironmentError: + except OSError: # pass to next try-except level util.reraise(*sys.exc_info()) except Exception: @@ -199,7 +198,7 @@ def handle_request(self, listener, req, client, addr): try: client.shutdown(socket.SHUT_RDWR) client.close() - except EnvironmentError: + except OSError: pass raise StopIteration() raise diff --git a/gunicorn/workers/workertmp.py b/gunicorn/workers/workertmp.py index a9ae39de0..8ef00a560 100644 --- a/gunicorn/workers/workertmp.py +++ b/gunicorn/workers/workertmp.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -14,7 +13,7 @@ IS_CYGWIN = PLATFORM.startswith('CYGWIN') -class WorkerTmp(object): +class WorkerTmp: def __init__(self, cfg): old_umask = os.umask(cfg.umask) diff --git a/tests/t.py b/tests/t.py index 9b76e7deb..4f1fcaf50 100644 --- a/tests/t.py +++ b/tests/t.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # Copyright 2009 Paul J. Davis # # This file is part of gunicorn released under the MIT license. @@ -22,7 +21,7 @@ def data_source(fname): return buf -class request(object): +class request: def __init__(self, name): self.fname = os.path.join(dirname, "requests", name) @@ -34,7 +33,7 @@ def run(): return run -class FakeSocket(object): +class FakeSocket: def __init__(self, data): self.tmp = tempfile.TemporaryFile() diff --git a/tests/test_arbiter.py b/tests/test_arbiter.py index e856282c8..8c1527e26 100644 --- a/tests/test_arbiter.py +++ b/tests/test_arbiter.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_config.py b/tests/test_config.py index f41edc4d5..6ca014b6a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. @@ -33,7 +32,7 @@ def paster_ini(): return os.path.join(dirname, "..", "examples", "frameworks", "pylonstest", "nose.ini") -class AltArgs(object): +class AltArgs: def __init__(self, args=None): self.args = args or [] self.orig = sys.argv @@ -115,7 +114,7 @@ def test_property_access(): # Not a config property pytest.raises(AttributeError, getattr, c, "foo") # Force to be not an error - class Baz(object): + class Baz: def get(self): return 3.14 c.settings["foo"] = Baz() diff --git a/tests/test_http.py b/tests/test_http.py index f0ddc3bb2..3aa4808f9 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -1,5 +1,3 @@ -# -*- encoding: utf-8 -*- - import io import t import pytest diff --git a/tests/test_invalid_requests.py b/tests/test_invalid_requests.py index a4748640f..63224d07d 100644 --- a/tests/test_invalid_requests.py +++ b/tests/test_invalid_requests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_pidfile.py b/tests/test_pidfile.py index ecbc052ff..81bb9d206 100644 --- a/tests/test_pidfile.py +++ b/tests/test_pidfile.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_sock.py b/tests/test_sock.py index adc348c6f..c3251af8c 100644 --- a/tests/test_sock.py +++ b/tests/test_sock.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_ssl.py b/tests/test_ssl.py index a31c1fe0f..6faea635d 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 - - # Copyright 2013 Dariusz Suchojad # # This file is part of gunicorn released under the MIT license. diff --git a/tests/test_statsd.py b/tests/test_statsd.py index 6f7bf426b..88adb0040 100644 --- a/tests/test_statsd.py +++ b/tests/test_statsd.py @@ -15,7 +15,7 @@ class StatsdTestException(Exception): pass -class MockSocket(object): +class MockSocket: "Pretend to be a UDP socket" def __init__(self, failp): self.failp = failp diff --git a/tests/test_systemd.py b/tests/test_systemd.py index ff8b959a0..d9ef8afc4 100644 --- a/tests/test_systemd.py +++ b/tests/test_systemd.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_util.py b/tests/test_util.py index b7ba6e010..35e544f9e 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/test_valid_requests.py b/tests/test_valid_requests.py index 8c6290cdd..2c71622c4 100644 --- a/tests/test_valid_requests.py +++ b/tests/test_valid_requests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/treq.py b/tests/treq.py index aeaae151f..fbe54700e 100644 --- a/tests/treq.py +++ b/tests/treq.py @@ -39,7 +39,7 @@ def load_py(fname): return vars(mod) -class request(object): +class request: def __init__(self, fname, expect): self.fname = fname self.name = os.path.basename(fname) diff --git a/tests/workers/test_geventlet.py b/tests/workers/test_geventlet.py index 06c7b5305..446f7037b 100644 --- a/tests/workers/test_geventlet.py +++ b/tests/workers/test_geventlet.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. diff --git a/tests/workers/test_ggevent.py b/tests/workers/test_ggevent.py index 261ce40df..f9a7bbfad 100644 --- a/tests/workers/test_ggevent.py +++ b/tests/workers/test_ggevent.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information.