Merge pull request #3189 from pajod/patch-py36

chore: eat Python 2 leftovers
This commit is contained in:
Benoit Chesneau 2024-08-10 10:40:40 +02:00 committed by GitHub
commit e75c3533e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
68 changed files with 68 additions and 133 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# #
# Gunicorn documentation build configuration file # Gunicorn documentation build configuration file
# #

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# An example of how to pass information from the command line to # An example of how to pass information from the command line to
# a WSGI app. Only applies to the native WSGI workers used by # a WSGI app. Only applies to the native WSGI workers used by

View File

@ -1,4 +1,3 @@
raise RuntimeError("Bad app!") raise RuntimeError("Bad app!")
def app(environ, start_response): def app(environ, start_response):

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,7 +1,7 @@
import cherrypy import cherrypy
class Root(object): class Root:
@cherrypy.expose @cherrypy.expose
def index(self): def index(self):
return 'Hello World!' return 'Hello World!'

View File

@ -8,7 +8,7 @@ def child_process(queue):
requests.get('http://requestb.in/15s95oz1') requests.get('http://requestb.in/15s95oz1')
class GunicornSubProcessTestMiddleware(object): class GunicornSubProcessTestMiddleware:
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.queue = Queue() self.queue = Queue()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -7,7 +6,7 @@
import sys import sys
import time import time
class TestIter(object): class TestIter:
def __iter__(self): def __iter__(self):
lines = [b'line 1\n', b'line 2\n'] lines = [b'line 1\n', b'line 2\n']

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -25,7 +24,7 @@ from test import app as app1
from test import app as app2 from test import app as app2
class Application(object): class Application:
def __init__(self): def __init__(self):
self.map = Mapper() self.map = Mapper()
self.map.connect('app1', '/app1url', app=app1) self.map.connect('app1', '/app1url', app=app1)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
# #
# An example of a standalone application using the internal API of Gunicorn. # An example of a standalone application using the internal API of Gunicorn.
# #

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
import collections import collections
import errno import errno
import re import re
@ -17,7 +16,7 @@ logger = logging.getLogger(__name__)
WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
class WebSocketWSGI(object): class WebSocketWSGI:
def __init__(self, handler): def __init__(self, handler):
self.handler = handler self.handler = handler
@ -118,7 +117,7 @@ class WebSocketWSGI(object):
# doesn't barf on the fact that we didn't call start_response # doesn't barf on the fact that we didn't call start_response
return ALREADY_HANDLED return ALREADY_HANDLED
class WebSocket(object): class WebSocket:
"""A websocket object that handles the details of """A websocket object that handles the details of
serialization/deserialization to the socket. serialization/deserialization to the socket.

View File

@ -1,4 +1,3 @@
import collections import collections
import errno import errno
import re import re
@ -18,7 +17,7 @@ logger = logging.getLogger(__name__)
WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
class WebSocketWSGI(object): class WebSocketWSGI:
def __init__(self, handler): def __init__(self, handler):
self.handler = handler self.handler = handler
@ -119,7 +118,7 @@ class WebSocketWSGI(object):
# doesn't barf on the fact that we didn't call start_response # doesn't barf on the fact that we didn't call start_response
return ALREADY_HANDLED return ALREADY_HANDLED
class WebSocket(object): class WebSocket:
"""A websocket object that handles the details of """A websocket object that handles the details of
serialization/deserialization to the socket. serialization/deserialization to the socket.

View File

@ -17,7 +17,7 @@ class MemoryWatch(threading.Thread):
def memory_usage(self, pid): def memory_usage(self, pid):
try: try:
out = commands.getoutput("ps -o rss -p %s" % pid) out = commands.getoutput("ps -o rss -p %s" % pid)
except IOError: except OSError:
return -1 return -1
used_mem = sum(int(x) for x in out.split('\n')[1:]) used_mem = sum(int(x) for x in out.split('\n')[1:])
return used_mem return used_mem

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -14,7 +13,7 @@ from gunicorn.config import Config, get_default_config_file
from gunicorn import debug from gunicorn import debug
class BaseApplication(object): class BaseApplication:
""" """
An application interface for configuring and loading An application interface for configuring and loading
the various necessities for any given web framework. the various necessities for any given web framework.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -18,7 +17,7 @@ from gunicorn import sock, systemd, util
from gunicorn import __version__, SERVER_SOFTWARE from gunicorn import __version__, SERVER_SOFTWARE
class Arbiter(object): class Arbiter:
""" """
Arbiter maintain the workers processes alive. It launches or Arbiter maintain the workers processes alive. It launches or
kills them if needed. It also manages application reloading kills them if needed. It also manages application reloading
@ -333,7 +332,7 @@ class Arbiter(object):
""" """
try: try:
os.write(self.PIPE[1], b'.') os.write(self.PIPE[1], b'.')
except IOError as e: except OSError as e:
if e.errno not in [errno.EAGAIN, errno.EINTR]: if e.errno not in [errno.EAGAIN, errno.EINTR]:
raise raise
@ -362,7 +361,7 @@ class Arbiter(object):
return return
while os.read(self.PIPE[0], 1): while os.read(self.PIPE[0], 1):
pass pass
except (select.error, OSError) as e: except OSError as e:
# TODO: select.error is a subclass of OSError since Python 3.3. # TODO: select.error is a subclass of OSError since Python 3.3.
error_number = getattr(e, 'errno', e.args[0]) error_number = getattr(e, 'errno', e.args[0])
if error_number not in [errno.EAGAIN, errno.EINTR]: if error_number not in [errno.EAGAIN, errno.EINTR]:

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -44,7 +43,7 @@ def auto_int(_, x):
return int(x, 0) return int(x, 0)
class Config(object): class Config:
def __init__(self, usage=None, prog=None): def __init__(self, usage=None, prog=None):
self.settings = make_settings() self.settings = make_settings()
@ -256,7 +255,7 @@ class SettingMeta(type):
setattr(cls, "short", desc.splitlines()[0]) setattr(cls, "short", desc.splitlines()[0])
class Setting(object): class Setting:
name = None name = None
value = None value = None
section = None section = None

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -16,7 +15,7 @@ __all__ = ['spew', 'unspew']
_token_spliter = re.compile(r'\W+') _token_spliter = re.compile(r'\W+')
class Spew(object): class Spew:
def __init__(self, trace_names=None, show_values=True): def __init__(self, trace_names=None, show_values=True):
self.trace_names = trace_names self.trace_names = trace_names
@ -37,7 +36,7 @@ class Spew(object):
try: try:
src = inspect.getsourcelines(frame) src = inspect.getsourcelines(frame)
line = src[lineno] line = src[lineno]
except IOError: except OSError:
line = 'Unknown code named [%s]. VM instruction #%d' % ( line = 'Unknown code named [%s]. VM instruction #%d' % (
frame.f_code.co_name, frame.f_lasti) frame.f_code.co_name, frame.f_lasti)
if self.trace_names is None or name in self.trace_names: if self.trace_names is None or name in self.trace_names:

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -162,7 +161,7 @@ def parse_syslog_address(addr):
return (socktype, (host, port)) return (socktype, (host, port))
class Logger(object): class Logger:
LOG_LEVELS = { LOG_LEVELS = {
"critical": logging.CRITICAL, "critical": logging.CRITICAL,

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -10,7 +9,7 @@ from gunicorn.http.errors import (NoMoreData, ChunkMissingTerminator,
InvalidChunkSize) InvalidChunkSize)
class ChunkedReader(object): class ChunkedReader:
def __init__(self, req, unreader): def __init__(self, req, unreader):
self.req = req self.req = req
self.parser = self.parse_chunked(unreader) self.parser = self.parse_chunked(unreader)
@ -113,7 +112,7 @@ class ChunkedReader(object):
buf.write(data) buf.write(data)
class LengthReader(object): class LengthReader:
def __init__(self, unreader, length): def __init__(self, unreader, length):
self.unreader = unreader self.unreader = unreader
self.length = length self.length = length
@ -143,7 +142,7 @@ class LengthReader(object):
return ret return ret
class EOFReader(object): class EOFReader:
def __init__(self, unreader): def __init__(self, unreader):
self.unreader = unreader self.unreader = unreader
self.buf = io.BytesIO() self.buf = io.BytesIO()
@ -181,7 +180,7 @@ class EOFReader(object):
return ret return ret
class Body(object): class Body:
def __init__(self, reader): def __init__(self, reader):
self.reader = reader self.reader = reader
self.buf = io.BytesIO() self.buf = io.BytesIO()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -31,7 +30,7 @@ VERSION_RE = re.compile(r"HTTP/(\d)\.(\d)")
RFC9110_5_5_INVALID_AND_DANGEROUS = re.compile(r"[\0\r\n]") RFC9110_5_5_INVALID_AND_DANGEROUS = re.compile(r"[\0\r\n]")
class Message(object): class Message:
def __init__(self, cfg, unreader, peer_addr): def __init__(self, cfg, unreader, peer_addr):
self.cfg = cfg self.cfg = cfg
self.unreader = unreader self.unreader = unreader
@ -376,13 +375,13 @@ class Request(Message):
try: try:
socket.inet_pton(socket.AF_INET, s_addr) socket.inet_pton(socket.AF_INET, s_addr)
socket.inet_pton(socket.AF_INET, d_addr) socket.inet_pton(socket.AF_INET, d_addr)
except socket.error: except OSError:
raise InvalidProxyLine(line) raise InvalidProxyLine(line)
elif proto == "TCP6": elif proto == "TCP6":
try: try:
socket.inet_pton(socket.AF_INET6, s_addr) socket.inet_pton(socket.AF_INET6, s_addr)
socket.inet_pton(socket.AF_INET6, d_addr) socket.inet_pton(socket.AF_INET6, d_addr)
except socket.error: except OSError:
raise InvalidProxyLine(line) raise InvalidProxyLine(line)
try: try:

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -7,7 +6,7 @@ from gunicorn.http.message import Request
from gunicorn.http.unreader import SocketUnreader, IterUnreader from gunicorn.http.unreader import SocketUnreader, IterUnreader
class Parser(object): class Parser:
mesg_class = None mesg_class = None

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -10,7 +9,7 @@ import os
# a given type of data source. # a given type of data source.
class Unreader(object): class Unreader:
def __init__(self): def __init__(self):
self.buf = io.BytesIO() self.buf = io.BytesIO()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -25,7 +24,7 @@ HEADER_VALUE_RE = re.compile(r'[ \t\x21-\x7e\x80-\xff]*')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class FileWrapper(object): class FileWrapper:
def __init__(self, filelike, blksize=8192): def __init__(self, filelike, blksize=8192):
self.filelike = filelike self.filelike = filelike
@ -198,7 +197,7 @@ def create(req, sock, client, server, cfg):
return resp, environ return resp, environ
class Response(object): class Response:
def __init__(self, req, sock, cfg): def __init__(self, req, sock, cfg):
self.req = req self.req = req

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -8,7 +7,7 @@ import os
import tempfile import tempfile
class Pidfile(object): class Pidfile:
"""\ """\
Manage a PID file. If a specific name is provided Manage a PID file. If a specific name is provided
it and '"%s.oldpid" % name' will be used. Otherwise it and '"%s.oldpid" % name' will be used. Otherwise
@ -52,7 +51,7 @@ class Pidfile(object):
def unlink(self): def unlink(self):
""" delete pidfile""" """ delete pidfile"""
try: try:
with open(self.fname, "r") as f: with open(self.fname) as f:
pid1 = int(f.read() or 0) pid1 = int(f.read() or 0)
if pid1 == self.pid: if pid1 == self.pid:
@ -65,7 +64,7 @@ class Pidfile(object):
if not self.fname: if not self.fname:
return return
try: try:
with open(self.fname, "r") as f: with open(self.fname) as f:
try: try:
wpid = int(f.read()) wpid = int(f.read())
except ValueError: except ValueError:
@ -80,7 +79,7 @@ class Pidfile(object):
if e.args[0] == errno.ESRCH: if e.args[0] == errno.ESRCH:
return return
raise raise
except IOError as e: except OSError as e:
if e.args[0] == errno.ENOENT: if e.args[0] == errno.ENOENT:
return return
raise raise

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -117,7 +116,7 @@ if has_inotify:
else: else:
class InotifyReloader(object): class InotifyReloader:
def __init__(self, extra_files=None, callback=None): def __init__(self, extra_files=None, callback=None):
raise ImportError('You must have the inotify module installed to ' raise ImportError('You must have the inotify module installed to '
'use the inotify reloader') 'use the inotify reloader')

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -14,7 +13,7 @@ import time
from gunicorn import util from gunicorn import util
class BaseSocket(object): class BaseSocket:
def __init__(self, address, conf, log, fd=None): def __init__(self, address, conf, log, fd=None):
self.log = log self.log = log
@ -43,7 +42,7 @@ class BaseSocket(object):
and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover
try: try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) 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): if err.errno not in (errno.ENOPROTOOPT, errno.EINVAL):
raise raise
if not bound: if not bound:
@ -66,7 +65,7 @@ class BaseSocket(object):
try: try:
self.sock.close() self.sock.close()
except socket.error as e: except OSError as e:
self.log.info("Error while closing socket %s", str(e)) self.log.info("Error while closing socket %s", str(e))
self.sock = None self.sock = None
@ -183,7 +182,7 @@ def create_sockets(conf, log, fds=None):
for i in range(5): for i in range(5):
try: try:
sock = sock_type(addr, conf, log) sock = sock_type(addr, conf, log)
except socket.error as e: except OSError as e:
if e.args[0] == errno.EADDRINUSE: if e.args[0] == errno.EADDRINUSE:
log.error("Connection in use: %s", str(addr)) log.error("Connection in use: %s", str(addr))
if e.args[0] == errno.EADDRNOTAVAIL: if e.args[0] == errno.EADDRNOTAVAIL:

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -217,7 +216,7 @@ def unlink(filename):
def is_ipv6(addr): def is_ipv6(addr):
try: try:
socket.inet_pton(socket.AF_INET6, addr) socket.inet_pton(socket.AF_INET6, addr)
except socket.error: # not a valid address except OSError: # not a valid address
return False return False
except ValueError: # ipv6 not supported on this platform except ValueError: # ipv6 not supported on this platform
return False return False
@ -269,7 +268,7 @@ def set_non_blocking(fd):
def close(sock): def close(sock):
try: try:
sock.close() sock.close()
except socket.error: except OSError:
pass pass
@ -566,7 +565,7 @@ def check_is_writable(path):
try: try:
with open(path, 'a') as f: with open(path, 'a') as f:
f.close() f.close()
except IOError as e: except OSError as e:
raise RuntimeError("Error: '%s' isn't writable [%r]" % (path, 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 # check BytesIO case and maybe others
try: try:
obj.fileno() obj.fileno()
except (AttributeError, IOError, io.UnsupportedOperation): except (AttributeError, OSError, io.UnsupportedOperation):
return False return False
return True return True

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -28,7 +27,7 @@ from gunicorn.reloader import reloader_engines
from gunicorn.workers.workertmp import WorkerTmp from gunicorn.workers.workertmp import WorkerTmp
class Worker(object): class Worker:
SIGNALS = [getattr(signal, "SIG%s" % x) for x in ( SIGNALS = [getattr(signal, "SIG%s" % x) for x in (
"ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split() "ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -60,7 +59,7 @@ class AsyncWorker(base.Worker):
except ssl.SSLError: except ssl.SSLError:
# pass to next try-except level # pass to next try-except level
util.reraise(*sys.exc_info()) util.reraise(*sys.exc_info())
except EnvironmentError: except OSError:
# pass to next try-except level # pass to next try-except level
util.reraise(*sys.exc_info()) util.reraise(*sys.exc_info())
except Exception as e: except Exception as e:
@ -72,7 +71,7 @@ class AsyncWorker(base.Worker):
else: else:
self.log.debug("Error processing SSL request.") self.log.debug("Error processing SSL request.")
self.handle_error(req, client, addr, e) 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): if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.") self.log.exception("Socket error processing request.")
else: else:
@ -124,7 +123,7 @@ class AsyncWorker(base.Worker):
raise StopIteration() raise StopIteration()
except StopIteration: except StopIteration:
raise raise
except EnvironmentError: except OSError:
# If the original exception was a socket.error we delegate # If the original exception was a socket.error we delegate
# handling it to the caller (where handle() might ignore it) # handling it to the caller (where handle() might ignore it)
util.reraise(*sys.exc_info()) util.reraise(*sys.exc_info())
@ -136,7 +135,7 @@ class AsyncWorker(base.Worker):
try: try:
sock.shutdown(socket.SHUT_RDWR) sock.shutdown(socket.SHUT_RDWR)
sock.close() sock.close()
except EnvironmentError: except OSError:
pass pass
raise StopIteration() raise StopIteration()
raise raise

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -147,7 +146,7 @@ class GeventWorker(AsyncWorker):
super().init_process() super().init_process()
class GeventResponse(object): class GeventResponse:
status = None status = None
headers = None headers = None

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -31,7 +30,7 @@ from .. import sock
from ..http import wsgi from ..http import wsgi
class TConn(object): class TConn:
def __init__(self, cfg, sock, client, server): def __init__(self, cfg, sock, client, server):
self.cfg = cfg self.cfg = cfg
@ -128,7 +127,7 @@ class ThreadWorker(base.Worker):
with self._lock: with self._lock:
self.poller.register(conn.sock, selectors.EVENT_READ, self.poller.register(conn.sock, selectors.EVENT_READ,
partial(self.on_client_socket_readable, conn)) partial(self.on_client_socket_readable, conn))
except EnvironmentError as e: except OSError as e:
if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, if e.errno not in (errno.EAGAIN, errno.ECONNABORTED,
errno.EWOULDBLOCK): errno.EWOULDBLOCK):
raise raise
@ -171,7 +170,7 @@ class ThreadWorker(base.Worker):
with self._lock: with self._lock:
try: try:
self.poller.unregister(conn.sock) self.poller.unregister(conn.sock)
except EnvironmentError as e: except OSError as e:
if e.errno != errno.EBADF: if e.errno != errno.EBADF:
raise raise
except KeyError: except KeyError:
@ -295,7 +294,7 @@ class ThreadWorker(base.Worker):
self.log.debug("Error processing SSL request.") self.log.debug("Error processing SSL request.")
self.handle_error(req, conn.sock, conn.client, e) 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): if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.") self.log.exception("Socket error processing request.")
else: else:
@ -349,7 +348,7 @@ class ThreadWorker(base.Worker):
if resp.should_close(): if resp.should_close():
self.log.debug("Closing connection.") self.log.debug("Closing connection.")
return False return False
except EnvironmentError: except OSError:
# pass to next try-except level # pass to next try-except level
util.reraise(*sys.exc_info()) util.reraise(*sys.exc_info())
except Exception: except Exception:
@ -360,7 +359,7 @@ class ThreadWorker(base.Worker):
try: try:
conn.sock.shutdown(socket.SHUT_RDWR) conn.sock.shutdown(socket.SHUT_RDWR)
conn.sock.close() conn.sock.close()
except EnvironmentError: except OSError:
pass pass
raise StopIteration() raise StopIteration()
raise raise

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -135,7 +134,7 @@ class TornadoWorker(Worker):
def on_close(instance, server_conn): def on_close(instance, server_conn):
self.handle_request() self.handle_request()
super(_HTTPServer, instance).on_close(server_conn) super().on_close(server_conn)
server_class = _HTTPServer server_class = _HTTPServer

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -40,7 +39,7 @@ class SyncWorker(base.Worker):
os.read(self.PIPE[0], 1) os.read(self.PIPE[0], 1)
return ret[0] return ret[0]
except select.error as e: except OSError as e:
if e.args[0] == errno.EINTR: if e.args[0] == errno.EINTR:
return self.sockets return self.sockets
if e.args[0] == errno.EBADF: if e.args[0] == errno.EBADF:
@ -73,7 +72,7 @@ class SyncWorker(base.Worker):
# process. # process.
continue continue
except EnvironmentError as e: except OSError as e:
if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, if e.errno not in (errno.EAGAIN, errno.ECONNABORTED,
errno.EWOULDBLOCK): errno.EWOULDBLOCK):
raise raise
@ -102,7 +101,7 @@ class SyncWorker(base.Worker):
try: try:
self.accept(listener) self.accept(listener)
except EnvironmentError as e: except OSError as e:
if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, if e.errno not in (errno.EAGAIN, errno.ECONNABORTED,
errno.EWOULDBLOCK): errno.EWOULDBLOCK):
raise raise
@ -144,7 +143,7 @@ class SyncWorker(base.Worker):
else: else:
self.log.debug("Error processing SSL request.") self.log.debug("Error processing SSL request.")
self.handle_error(req, client, addr, e) 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): if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.") self.log.exception("Socket error processing request.")
else: else:
@ -188,7 +187,7 @@ class SyncWorker(base.Worker):
self.log.access(resp, req, environ, request_time) self.log.access(resp, req, environ, request_time)
if hasattr(respiter, "close"): if hasattr(respiter, "close"):
respiter.close() respiter.close()
except EnvironmentError: except OSError:
# pass to next try-except level # pass to next try-except level
util.reraise(*sys.exc_info()) util.reraise(*sys.exc_info())
except Exception: except Exception:
@ -199,7 +198,7 @@ class SyncWorker(base.Worker):
try: try:
client.shutdown(socket.SHUT_RDWR) client.shutdown(socket.SHUT_RDWR)
client.close() client.close()
except EnvironmentError: except OSError:
pass pass
raise StopIteration() raise StopIteration()
raise raise

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -14,7 +13,7 @@ PLATFORM = platform.system()
IS_CYGWIN = PLATFORM.startswith('CYGWIN') IS_CYGWIN = PLATFORM.startswith('CYGWIN')
class WorkerTmp(object): class WorkerTmp:
def __init__(self, cfg): def __init__(self, cfg):
old_umask = os.umask(cfg.umask) old_umask = os.umask(cfg.umask)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# Copyright 2009 Paul J. Davis <paul.joseph.davis@gmail.com> # Copyright 2009 Paul J. Davis <paul.joseph.davis@gmail.com>
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
@ -22,7 +21,7 @@ def data_source(fname):
return buf return buf
class request(object): class request:
def __init__(self, name): def __init__(self, name):
self.fname = os.path.join(dirname, "requests", name) self.fname = os.path.join(dirname, "requests", name)
@ -34,7 +33,7 @@ class request(object):
return run return run
class FakeSocket(object): class FakeSocket:
def __init__(self, data): def __init__(self, data):
self.tmp = tempfile.TemporaryFile() self.tmp = tempfile.TemporaryFile()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
@ -33,7 +32,7 @@ def paster_ini():
return os.path.join(dirname, "..", "examples", "frameworks", "pylonstest", "nose.ini") return os.path.join(dirname, "..", "examples", "frameworks", "pylonstest", "nose.ini")
class AltArgs(object): class AltArgs:
def __init__(self, args=None): def __init__(self, args=None):
self.args = args or [] self.args = args or []
self.orig = sys.argv self.orig = sys.argv
@ -115,7 +114,7 @@ def test_property_access():
# Not a config property # Not a config property
pytest.raises(AttributeError, getattr, c, "foo") pytest.raises(AttributeError, getattr, c, "foo")
# Force to be not an error # Force to be not an error
class Baz(object): class Baz:
def get(self): def get(self):
return 3.14 return 3.14
c.settings["foo"] = Baz() c.settings["foo"] = Baz()

View File

@ -1,5 +1,3 @@
# -*- encoding: utf-8 -*-
import io import io
import t import t
import pytest import pytest

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -
# Copyright 2013 Dariusz Suchojad <dsuch at zato.io> # Copyright 2013 Dariusz Suchojad <dsuch at zato.io>
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.

View File

@ -15,7 +15,7 @@ class StatsdTestException(Exception):
pass pass
class MockSocket(object): class MockSocket:
"Pretend to be a UDP socket" "Pretend to be a UDP socket"
def __init__(self, failp): def __init__(self, failp):
self.failp = failp self.failp = failp

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -39,7 +39,7 @@ def load_py(fname):
return vars(mod) return vars(mod)
class request(object): class request:
def __init__(self, fname, expect): def __init__(self, fname, expect):
self.fname = fname self.fname = fname
self.name = os.path.basename(fname) self.name = os.path.basename(fname)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -
# #
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.