Commit 1a55d53e authored by Jason Madden's avatar Jason Madden

Lint.

parent c5f76bef
......@@ -223,20 +223,15 @@ jobs:
python -c 'import gevent.core; print(gevent.core.loop)'
python -c 'import gevent.ares; print(gevent.ares)'
ccache -s
# Lint disabled while I get the build back in shape.
# - name: Lint (Python 3)
# if: matrix.python-version == '3.10' && startsWith(runner.os, 'Linux')
# # We only need to do this on one version, and it should be Python 3, because
# # pylint has stopped updating for Python 2.
# # We do this here rather than a separate job to avoid the compilation overhead.
# # TODO: Revisit this when we have caching of that part.
# # astroid 2.12.10 and pylint 2.15.3 encounter infinite
# # recursion in gevent/_ssl3.py on CI; I can't reproduce
# # locally on my Mac. Trying some different version pins to see
# # what we get
# run: |
# pip install -U 'pylint<2.15'
# python -m pylint --rcfile=.pylintrc gevent
- name: Lint
if: matrix.python-version == '3.11' && startsWith(runner.os, 'Linux')
# We only need to do this on one version.
# We do this here rather than a separate job to avoid the compilation overhead.
# TODO: Revisit this when we have caching of that part.
run: |
pip install -U pylint
python -m pylint --rcfile=.pylintrc gevent
- name: "Tests: Basic"
run: |
python -m gevent.tests --second-chance $G_USE_COV
......
[MAIN]
load-plugins=pylint.extensions.bad_builtin
[MASTER]
load-plugins=pylint.extensions.bad_builtin,
pylint.extensions.code_style,
pylint.extensions.dict_init_mutate,
pylint.extensions.dunder,
pylint.extensions.emptystring,
pylint.extensions.comparison_placement,
pylint.extensions.confusing_elif,
pylint.extensions.for_any_all,
pylint.extensions.consider_refactoring_into_while_condition,
pylint.extensions.check_elif,
pylint.extensions.eq_without_hash,
pylint.extensions.overlapping_exceptions,
# pylint.extensions.comparetozero,
# Takes out ``if x == 0:`` and wants you to write ``if not x:``
# but in many cases, the == 0 is actually much more clear.
# pylint.extensions.mccabe,
# We have too many too-complex methods. We should enable this and fix them
# one by one.
# pylint.extensions.redefined_variable_type,
# We use that pattern during initialization.
# magic_value wants you to not use arbitrary strings and numbers
# inline in the code. But it's overzealous and has way too many false
# positives. Trust people to do the most readable thing.
# pylint.extensions.magic_value
# Empty comment would be good, except it detects blank lines within
# a single comment block.
#
# Those are often used to separate paragraphs, like here.
# pylint.extensions.empty_comment,
# consider_ternary_expression is a nice check, but is also overzealous.
# Trust the human to do the readable thing.
# pylint.extensions.consider_ternary_expression,
# redefined_loop_name tends to catch us with things like
# for name in (a, b, c): name = name + '_column' ...
# pylint.extensions.redefined_loop_name,
# This wants you to turn ``x in (1, 2)`` into ``x in {1, 2}``.
# They both result in the LOAD_CONST bytecode, one a tuple one a
# frozenset. In theory a set lookup using hashing is faster than
# a linear scan of a tuple; but if the tuple is small, it can often
# actually be faster to scan the tuple.
# pylint.extensions.set_membership,
# Fix zope.cachedescriptors.property.Lazy; the property-classes doesn't seem to
# do anything.
# https://stackoverflow.com/questions/51160955/pylint-how-to-specify-a-self-defined-property-decorator-with-property-classes
# For releases prior to 2.14.2, this needs to be a one-line, quoted string. After that,
# a multi-line string.
# - Make zope.cachedescriptors.property.Lazy look like a property;
# fixes pylint thinking it is a method.
# - Run in Pure Python mode (ignore C extensions that respect this);
# fixes some issues with zope.interface, like IFoo.providedby(ob)
# claiming not to have the right number of parameters...except no, it does not.
init-hook =
import astroid.bases
astroid.bases.POSSIBLE_PROPERTIES.add('Lazy')
astroid.bases.POSSIBLE_PROPERTIES.add('LazyOnClass')
astroid.bases.POSSIBLE_PROPERTIES.add('readproperty')
astroid.bases.POSSIBLE_PROPERTIES.add('non_overridable')
import os
os.environ['PURE_PYTHON'] = ("1")
# Ending on a quoted string
# breaks pylint 2.14.5 (it strips the trailing quote. This is
# probably because it tries to handle one-line quoted strings as well as multi-blocks).
# The parens around it fix the issue.
extension-pkg-whitelist=gevent.greenlet,gevent.libuv._corecffi,gevent.libev._corecffi,gevent.libev._corecffi.lib,gevent.local,gevent._ident
# Control the amount of potential inferred values when inferring a single
......@@ -57,6 +127,9 @@ limit-inference-results=1
# Pylint 2.6+ adds some python-3-only things that don't apply: raise-missing-from, super-with-arguments, consider-using-f-string, redundant-u-string-prefix
# unnecessary-lambda-assignment: New check introduced in v2.14.0
# unnecessary-dunder-call: New check introduced in v2.14.0
# consider-using-assignment-expr: wants you to use the walrus operator.
# It hits way too much and its not clear they would be improvements.
# confusing-consecutive-elif: Are they though?
disable=wrong-import-position,
wrong-import-order,
missing-docstring,
......@@ -82,9 +155,15 @@ disable=wrong-import-position,
raise-missing-from,
super-with-arguments,
consider-using-f-string,
consider-using-assignment-expr,
redundant-u-string-prefix,
unnecessary-lambda-assignment,
unnecessary-dunder-call
unnecessary-dunder-call,
use-dict-literal,
confusing-consecutive-elif,
enable=consider-using-augmented-assign
[FORMAT]
# duplicated from setup.cfg
......
......@@ -116,7 +116,7 @@ if [ -d /gevent -a -d /opt/python ]; then
mkdir /gevent/wheelhouse
OPATH="$PATH"
which auditwheel
for variant in `ls -d /opt/python/cp{310,27,36,37,38,39,311}*`; do
for variant in `ls -d /opt/python/cp{310,38,39,311,312}*`; do
export PATH="$variant/bin:$OPATH"
echo "Building $variant $(python --version)"
......
......@@ -390,7 +390,7 @@ class Loop(ImportableSetting, Setting):
'libev-cffi',
]
shortname_map = {
shortname_map = { # pylint:disable=dict-init-mutate
'libev-cext': 'gevent.libev.corecext.loop',
'libev-cffi': 'gevent.libev.corecffi.loop',
'libuv-cffi': 'gevent.libuv.loop.loop',
......
......@@ -31,12 +31,11 @@ class callback(object):
# 'pending' has the same meaning as libev watchers: it is cleared before actually
# running the callback
def __nonzero__(self):
def __bool__(self):
# it's nonzero if it's pending or currently executing
# NOTE: This depends on loop._run_callbacks setting the args property
# to None.
return self.args is not None
__bool__ = __nonzero__
@property
def pending(self):
......
......@@ -178,20 +178,20 @@ class AbstractCallbacks(object):
# Keep it around so we can close it later.
the_watcher.loop._keepaliveset.add(the_watcher)
return -1
else:
if (the_watcher.loop is not None
and the_watcher in the_watcher.loop._keepaliveset
and the_watcher._watcher is orig_ffi_watcher):
# It didn't stop itself, *and* it didn't stop itself, reset
# its watcher, and start itself again. libuv's io watchers
# multiplex and may do this.
# The normal, expected scenario when we find the watcher still
# in the keepaliveset is that it is still active at the event loop
# level, so we don't expect that python_stop gets called.
#_dbg("The watcher has not stopped itself, possibly still active", the_watcher)
return 1
return 2 # it stopped itself
if (the_watcher.loop is not None
and the_watcher in the_watcher.loop._keepaliveset
and the_watcher._watcher is orig_ffi_watcher):
# It didn't stop itself, *and* it didn't stop itself, reset
# its watcher, and start itself again. libuv's io watchers
# multiplex and may do this.
# The normal, expected scenario when we find the watcher still
# in the keepaliveset is that it is still active at the event loop
# level, so we don't expect that python_stop gets called.
#_dbg("The watcher has not stopped itself, possibly still active", the_watcher)
return 1
return 2 # it stopped itself
def python_handle_error(self, handle, _revents):
_dbg("Handling error for handle", handle)
......
......@@ -84,7 +84,7 @@ def events_to_str(event_field, all_events):
c_flag = flag
if event_field & c_flag:
result.append(string)
event_field = event_field & (~c_flag)
event_field &= (~c_flag)
if not event_field:
break
if event_field:
......
......@@ -154,7 +154,7 @@ class GreenFileDescriptorIO(RawIOBase):
while 1:
try:
return _read(self._fileno, n)
except (IOError, OSError) as ex:
except OSError as ex:
if ex.args[0] not in ignored_errors:
raise
wait_on_watcher(self._read_watcher, None, None, self.hub)
......@@ -192,7 +192,7 @@ class GreenFileDescriptorIO(RawIOBase):
while True:
try:
return _write(self._fileno, b)
except (IOError, OSError) as ex:
except OSError as ex:
if ex.args[0] not in ignored_errors:
raise
wait_on_watcher(self._write_watcher, None, None, self.hub)
......
......@@ -50,6 +50,9 @@ class _MonitorEntry(object):
def __eq__(self, other):
return self.function == other.function and self.period == other.period
def __hash__(self):
return hash((self.function, self.period))
def __repr__(self):
return repr((self.function, self.period, self.last_run_time))
......
......@@ -9,7 +9,7 @@ Python 3 socket module.
from __future__ import absolute_import
import io
import os
import sys
from gevent import _socketcommon
from gevent._util import copy_globals
......@@ -51,7 +51,7 @@ class _closedsocket(object):
detach = fileno
def _dummy(*args, **kwargs): # pylint:disable=no-method-argument,unused-argument
def _dummy(*args, **kwargs): # pylint:disable=no-method-argument,unused-argument,no-self-argument
raise OSError(EBADF, 'Bad file descriptor')
# All _delegate_methods must also be initialized here.
send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
......@@ -311,6 +311,7 @@ class socket(_socketcommon.SocketMixin):
# Break any reference to the loop.io objects. Our fileno,
# which they were tied to, is about to be free to be reused, so these
# objects are no longer functional.
# pylint:disable-next=superfluous-parens
self._drop_events_and_close(closefd=(reason == 'closed'))
self._sock = _closedsocket(family, type, proto, fileno, reason)
......
......@@ -224,6 +224,7 @@ def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
# function simply with integers.
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
result = [
# pylint:disable=undefined-variable
(_intenum_converter(af, AddressFamily),
_intenum_converter(socktype, SocketKind),
proto, canonname, sa)
......@@ -527,7 +528,9 @@ class SocketMixin(object):
self.hub.cancel_wait(self._write_event, cancel_wait_ex)
self._sock.shutdown(how)
# pylint:disable-next=undefined-variable
family = property(lambda self: _intenum_converter(self._sock.family, AddressFamily))
# pylint:disable-next=undefined-variable
type = property(lambda self: _intenum_converter(self._sock.type, SocketKind))
proto = property(lambda self: self._sock.proto)
......
......@@ -30,7 +30,7 @@ Taken verbatim from Jinja2.
https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267
"""
# pylint:disable=consider-using-dict-comprehension
# pylint:disable=consider-using-dict-comprehension,bad-dunder-name
#import platform # XXX: gevent cannot import platform at the top level; interferes with monkey patching
import sys
......
......@@ -378,7 +378,7 @@ class Greenlet(greenlet):
hub = get_my_hub(self) # pylint:disable=undefined-variable
return hub.loop
def __nonzero__(self):
def __nonzero__(self): # pylint:disable=bad-dunder-name
return self._start_event is not None and self._exc_info is None
try:
__bool__ = __nonzero__ # Python 3
......
......@@ -116,6 +116,7 @@ class loop(AbstractLoop):
self._io_watchers = {}
self._fork_watchers = set()
self._pid = os.getpid()
# pylint:disable-next=superfluous-parens
self._default = (self._ptr == libuv.uv_default_loop())
self._queued_callbacks = []
......
......@@ -204,6 +204,7 @@ class watcher(_base.watcher):
ref = property(_get_ref, _set_ref)
def feed(self, _revents, _callback, *_args):
# pylint:disable-next=broad-exception-raised
raise Exception("Not implemented")
class io(_base.IoMixin, watcher):
......@@ -602,6 +603,7 @@ class async_(_base.AsyncMixin, watcher):
def send(self):
assert self._callback is not async_._callback, "Sending to a closed watcher"
if libuv.uv_is_closing(self._watcher):
# pylint:disable-next=broad-exception-raised
raise Exception("Closing handle")
libuv.uv_async_send(self._watcher)
......
......@@ -366,7 +366,7 @@ class local(object):
"""
__slots__ = tuple(_local_attrs - {'__class__', '__cinit__'})
def __cinit__(self, *args, **kw):
def __cinit__(self, *args, **kw): # pylint:disable=bad-dunder-name
if args or kw:
if type(self).__init__ == object.__init__: # pylint:disable=comparison-with-callable
raise TypeError("Initialization arguments are not supported", args, kw)
......@@ -600,7 +600,7 @@ if local.__module__ == 'gevent.local':
local.__new__ = classmethod(__new__)
else: # pragma: no cover
# Make sure we revisit in case of changes to the (accelerator) module names.
if local.__module__ != 'gevent._gevent_clocal':
if local.__module__ != 'gevent._gevent_clocal': # pylint:disable=else-if-used
raise AssertionError("Module names changed (local: %r; __name__: %r); revisit this code" % (
local.__module__, __name__) )
......
......@@ -322,7 +322,7 @@ class RLock(object):
"""
me = getcurrent()
if self._owner is me:
self._count = self._count + 1
self._count += 1
return 1
rc = self._block.acquire(blocking, timeout)
if rc:
......@@ -344,7 +344,7 @@ class RLock(object):
raise RuntimeError("cannot release un-acquired lock. Owner: %r Current: %r" % (
self._owner, getcurrent()
))
self._count = count = self._count - 1
self._count = count = self._count - 1 # pylint:disable=consider-using-augmented-assign
if not count:
self._owner = None
self._block.release()
......
......@@ -44,7 +44,7 @@ to manage child processes.
from __future__ import absolute_import
import os
import sys
from gevent.hub import _get_hub_noargs as get_hub
from gevent.hub import reinit
from gevent._config import config
......
......@@ -989,7 +989,7 @@ class WSGIHandler(object):
finally:
try:
self.wsgi_input._discard()
except (socket.error, IOError):
except socket.error:
# Don't let exceptions during discarding
# input override any exception that may have been
# raised by the application, such as our own _InvalidClientInput.
......
......@@ -228,7 +228,7 @@ class Queue(object):
"""
return True
def __nonzero__(self):
def __nonzero__(self): # pylint:disable=bad-dunder-name
# Py2.
# For Cython; __bool__ becomes a special method that we can't
# get by name.
......
......@@ -149,8 +149,7 @@ def _is_addr(host, parse=_ipv4_inet_aton):
parse(host)
except AddressSyntaxError:
return False
else:
return True
return True
# Return True if host is a valid IPv4 address
is_ipv4_addr = _is_addr
......
......@@ -89,7 +89,7 @@ class HostsFile(object):
try:
load_time = os.stat(self.fname).st_mtime
needs_load = load_time > self._last_load
except (IOError, OSError):
except OSError:
from gevent import get_hub
get_hub().handle_error(self, *sys.exc_info())
needs_load = False
......
......@@ -70,8 +70,7 @@ def get_fileno(obj):
if not isinstance(obj, integer_types):
raise TypeError('argument must be an int, or have a fileno() method: %r' % (obj,))
return obj
else:
return fileno_f()
return fileno_f()
class SelectResult(object):
......
......@@ -15,7 +15,6 @@ from _socket import SOCK_DGRAM
from gevent.baseserver import BaseServer
from gevent.socket import EWOULDBLOCK
from gevent.socket import socket as GeventSocket
from gevent._compat import PYPY
__all__ = ['StreamServer', 'DatagramServer']
......
......@@ -59,14 +59,10 @@ from gevent.hub import linkproxy
from gevent.hub import sleep
from gevent.hub import getcurrent
from gevent._compat import integer_types, string_types, xrange
# from gevent._compat import PY3
# from gevent._compat import PY35
# from gevent._compat import PY36
# from gevent._compat import PY37
# from gevent._compat import PY38
from gevent._compat import PY311
from gevent._compat import PYPY
from gevent._compat import reraise
from gevent._compat import fsdecode
from gevent._compat import fsencode
from gevent._compat import PathLike
......@@ -539,7 +535,7 @@ class _CommunicatingGreenlets(object):
if hasattr(fobj, 'flush'):
# 3.6 started expecting flush to be called.
fobj.flush()
except (OSError, IOError, BrokenPipeError) as ex:
except (OSError, BrokenPipeError) as ex:
# Test cases from the stdlib can raise BrokenPipeError
# without setting an errno value. This matters because
# Python 2 doesn't have a BrokenPipeError.
......@@ -824,7 +820,7 @@ class Popen(object):
for f in filter(None, (self.stdin, self.stdout, self.stderr)):
try:
f.close()
except (OSError, IOError):
except OSError:
pass # Ignore EBADF or other errors.
if not self._closed_child_pipe_fds:
......@@ -840,7 +836,7 @@ class Popen(object):
for fd in to_close:
try:
os.close(fd)
except (OSError, IOError):
except OSError:
pass
raise
......@@ -1682,7 +1678,7 @@ class Popen(object):
# same fd more than once, or standard fds.
if not True:
closed = set([None])
for fd in [p2cread, c2pwrite, errwrite]:
for fd in (p2cread, c2pwrite, errwrite):
if fd not in closed and fd > 2:
os.close(fd)
closed.add(fd)
......
......@@ -82,7 +82,7 @@ def walk_modules(
if modpath is None:
modpath = 'gevent.'
else:
if modpath is None:
if modpath is None: # pylint:disable=else-if-used
modpath = ''
for fn in sorted(os.listdir(basedir)):
......
......@@ -34,7 +34,7 @@ from . import travis
# See https://bitbucket.org/pypy/pypy/issues/2769/systemerror-unexpected-internal-exception
try:
__import__('_testcapi')
except (ImportError, OSError, IOError):
except (ImportError, OSError):
# This can raise a wide variety of errors
pass
......@@ -521,7 +521,7 @@ class Discovery(object):
not os.path.exists(abs_filename)
and not filename.endswith('.py')
and os.path.exists(abs_filename + '.py') ):
abs_filename = abs_filename + '.py'
abs_filename += '.py'
with open(abs_filename, 'rb') as f:
# Some of the test files (e.g., test__socket_dns) are
......
......@@ -358,7 +358,7 @@ def _find_test_status(took, out):
if m:
skipped = _colorize('skipped', out[m.start():m.end()])
skipped_count = int(out[m.start(1):m.end(1)])
status = status % (took, skipped)
status = status % (took, skipped) # pylint:disable=consider-using-augmented-assign
if took > 10:
status = _colorize('slow-test', status)
return status, run_count, skipped_count
......
......@@ -17,9 +17,6 @@ class Condition(object):
def __or__(self, other):
return OrCondition(self, other)
def __nonzero__(self):
return self.__bool__()
def __bool__(self):
raise NotImplementedError
......@@ -184,7 +181,7 @@ class DefinitionsMeta(type):
# a metaclass on Python 3 that makes sure we only set attributes once. pylint doesn't
# warn about that.
@classmethod
def __prepare__(cls, name, bases): # pylint:disable=unused-argument
def __prepare__(mcs, name, bases): # pylint:disable=unused-argument,bad-dunder-name
return SetOnceMapping()
......
......@@ -10,21 +10,17 @@ else:
print(os.path.abspath(__file__))
if sys.version_info[:2] == (2, 7):
# Prior to gevent 1.3, 'python -m gevent.monkey' guaranteed this to be
# None for all python versions.
print(__package__ is None)
if sys.argv[1] == 'patched':
# __package__ is handled differently, for some reason, and
# runpy doesn't let us override it. When we call it, it
# becomes ''. This appears to be against the documentation for
# runpy, which says specifically "If the supplied path
# directly references a script file (whether as source or as
# precompiled byte code), then __file__ will be set to the
# supplied path, and __spec__, __cached__, __loader__ and
# __package__ will all be set to None."
print(__package__ == '') # pylint:disable=compare-to-empty-string
else:
if sys.argv[1] == 'patched':
# __package__ is handled differently, for some reason, and
# runpy doesn't let us override it. When we call it, it
# becomes ''. This appears to be against the documentation for
# runpy, which says specifically "If the supplied path
# directly references a script file (whether as source or as
# precompiled byte code), then __file__ will be set to the
# supplied path, and __spec__, __cached__, __loader__ and
# __package__ will all be set to None."
print(__package__ == '')
else:
# but the interpreter sets it to None
print(__package__ is None)
# but the interpreter sets it to None
print(__package__ is None)
......@@ -159,7 +159,7 @@ class Test(greentest.TestCase):
start = time.time()
with Timeout(XDELAY, False):
sleep(XDELAY * 2)
delta = (time.time() - start)
delta = time.time() - start
self.assertTimeWithinRange(delta, 0, XDELAY * 2)
# passing None as seconds disables the timer
......
......@@ -73,8 +73,8 @@ class Test(greentest.TestCase):
except:
conn.close()
raise
else:
conn.banner = banner
conn.banner = banner
return conn
def _wait_for_prompt(self, conn):
......
......@@ -37,7 +37,7 @@ def _find_files_to_ignore():
return result
default_time_range = (2, 10)
time_ranges = {
time_ranges = { # what is this even supposed to mean? pylint:disable=consider-using-namedtuple-or-dataclass
'concurrent_download.py': (0, 30),
'processes.py': (0, default_time_range[-1])
}
......
......@@ -34,7 +34,7 @@ def Writer(fobj, line):
def close_fd_quietly(fd):
try:
os.close(fd)
except (IOError, OSError):
except OSError:
pass
def skipUnlessWorksWithRegularFiles(func):
......@@ -275,7 +275,7 @@ class TestFileObjectBlock(CleanupMixin,
f.close()
try:
nf.close()
except (OSError, IOError):
except OSError:
# OSError: Py3, IOError: Py2
pass
self.assertEqual(f.name, fileno)
......
......@@ -68,7 +68,7 @@ class TestDestroyInChildWithActiveSpawn(unittest.TestCase):
hub.destroy(destroy_loop=True)
self.assertFalse(run)
os._exit(0)
return
return # pylint:disable=unreachable
# The parent.
# Briefly prevent us from spinning our event loop.
......
......@@ -47,7 +47,7 @@ class Test(greentest.TestCase):
def assert_raises_EBADF(self, func):
try:
result = func()
except (socket.error, OSError) as ex:
except OSError as ex:
# Windows/Py3 raises "OSError: [WinError 10038]"
if ex.args[0] == errno.EBADF:
return
......
......@@ -817,6 +817,7 @@ class TestUseWrite(TestCase):
write(self.body)
write(self.body)
else:
# pylint:disable-next=broad-exception-raised
raise Exception('Invalid url')
return [self.end]
......@@ -1145,8 +1146,7 @@ class TestContentLength304(TestCase):
except AssertionError as ex:
start_response('200 Raised', [])
return ex.args
else:
raise AssertionError('start_response did not fail but it should')
raise AssertionError('start_response did not fail but it should')
def test_err(self):
body = "Invalid Content-Length for 304 response: '100' (must be absent or zero)"
......@@ -1699,7 +1699,7 @@ class TestInputRaw(greentest.BaseTestCase):
data = b'asdf\nghij\n'
long_data = b'a' * (pywsgi.MAX_REQUEST_LINE + 10)
long_data += b'\n'
data = data + long_data
data += long_data
partial_data = b'qjk\n' # Note terminating \n
n = 25 * 1000000000
if hasattr(n, 'bit_length'):
......
......@@ -198,7 +198,7 @@ class TestTCP(greentest.TestCase):
# from generating ``ConnectionResetError`` on AppVeyor.
try:
client = client.unwrap()
except (ValueError, IOError, OSError):
except (ValueError, OSError):
# PyPy raises _cffi_ssl._stdssl.error.SSLSyscallError,
# which is an IOError in 2.7 and OSError in 3.7
pass
......@@ -214,7 +214,7 @@ class TestTCP(greentest.TestCase):
# lets do a shutdown everywhere, but only after removing any
# SSL wrapping.
client.shutdown(socket.SHUT_RDWR)
except (OSError, socket.error):
except OSError:
pass
log("Client will close")
......
......@@ -14,7 +14,7 @@ class TestClosedSocket(greentest.TestCase):
try:
sock.send(b'a', timeout=1)
self.fail("Should raise socket error")
except (socket.error, OSError) as ex:
except OSError as ex:
if ex.args[0] != errno.EBADF:
if sys.platform.startswith('win'):
# Windows/Py3 raises "OSError: [WinError 10038] "
......
......@@ -66,10 +66,8 @@ class TestLockThread(greentest.TestCase):
def background():
spawned.append(True)
while 1:
# blocking= in Py3, wait (no default, no name) in Py2
if lock.acquire(False):
break
while not lock.acquire(False):
pass
thread = threading.Thread(target=background)
# If lock.acquire(False) doesn't yield when it fails,
......
......@@ -510,7 +510,7 @@ class SomeClass(object):
def func(self, arg1, kwarg1=None):
result = Object()
self.refs.extend([weakref.ref(x) for x in [arg1, kwarg1, result]])
self.refs.extend([weakref.ref(x) for x in (arg1, kwarg1, result)])
return result
......
......@@ -40,7 +40,7 @@ class TestFormat(greentest.TestCase):
def test_with_Greenlet(self):
rl = local.local()
rl.foo = 1
rl.some_attr = 1
def root():
l = MyLocal(42)
assert l
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment