From 4445f3296b39b37229cdb7cd152ea06478a13d61 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Thu, 2 Apr 2020 15:01:37 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Remove hacking and friends from lower-constraints, they are not needed for installation. Change-Id: If75153300f07e6d1c5bf433af35a0dd4d98e6c7f --- benchmark/benchmark.py | 2 ++ lower-constraints.txt | 4 ---- oslo_rootwrap/jsonrpc.py | 7 ++++--- oslo_rootwrap/tests/run_daemon.py | 1 + oslo_rootwrap/tests/test_rootwrap.py | 4 ++-- test-requirements.txt | 2 +- tox.ini | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 2009eda..6788373 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -63,6 +63,7 @@ def run_one(runner, cmd): assert code == 0, "Command failed" return __inner + runners = [ ("{0}", run_plain), ("sudo {0}", run_sudo), @@ -109,5 +110,6 @@ def main(): atexit.register(run_sudo, ["ip", "netns", "delete", "bench_ns"]) run_bench('ip netns exec bench_ns ip a'.split(), runners[1:]) + if __name__ == "__main__": main() diff --git a/lower-constraints.txt b/lower-constraints.txt index 9a397d2..0daaef0 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -7,11 +7,9 @@ dulwich==0.15.0 eventlet==0.18.2 extras==1.0.0 fixtures==3.0.0 -flake8==2.5.5 gitdb==0.6.4 GitPython==1.0.1 greenlet==0.4.10 -hacking==0.12.0 imagesize==0.7.1 iso8601==0.1.11 Jinja2==2.10 @@ -24,8 +22,6 @@ openstackdocstheme==1.20.0 os-client-config==1.28.0 oslotest==3.2.0 pbr==2.0.0 -pep8==1.5.7 -pyflakes==0.8.1 Pygments==2.2.0 python-mimeparse==1.6.0 python-subunit==1.0.0 diff --git a/oslo_rootwrap/jsonrpc.py b/oslo_rootwrap/jsonrpc.py index 9dd0641..195febb 100644 --- a/oslo_rootwrap/jsonrpc.py +++ b/oslo_rootwrap/jsonrpc.py @@ -96,6 +96,7 @@ class JsonListener(object): def get_accepted(self): return self._accepted + if hasattr(managers.Server, 'accepter'): # In Python 3 accepter() thread has infinite loop. We break it with # EOFError, so we should silence this error here. @@ -118,10 +119,10 @@ class JsonConnection(object): self._socket.sendall(s) def recv_bytes(self, maxsize=None): - l = struct.unpack('!Q', self.recvall(8))[0] - if maxsize is not None and l > maxsize: + item = struct.unpack('!Q', self.recvall(8))[0] + if maxsize is not None and item > maxsize: raise RuntimeError("Too big message received") - s = self.recvall(l) + s = self.recvall(item) return s def send(self, obj): diff --git a/oslo_rootwrap/tests/run_daemon.py b/oslo_rootwrap/tests/run_daemon.py index 8483ff1..a39e4cf 100644 --- a/oslo_rootwrap/tests/run_daemon.py +++ b/oslo_rootwrap/tests/run_daemon.py @@ -49,6 +49,7 @@ class nonclosing(object): def close(self): pass + log_format = ("%(asctime)s | [%(process)5s]+%(levelname)5s | " "%(message)s") if __name__ == '__main__': diff --git a/oslo_rootwrap/tests/test_rootwrap.py b/oslo_rootwrap/tests/test_rootwrap.py index 112843e..d5a8c0a 100644 --- a/oslo_rootwrap/tests/test_rootwrap.py +++ b/oslo_rootwrap/tests/test_rootwrap.py @@ -398,7 +398,7 @@ class RootwrapTestCase(testtools.TestCase): def test_ChainingRegExpFilter_match(self): filter_list = [filters.ChainingRegExpFilter('nice', 'root', - 'nice', '-?\d+'), + 'nice', r'-?\d+'), filters.CommandFilter('cat', 'root')] args = ['nice', '5', 'cat', '/a'] dirs = ['/bin', '/usr/bin'] @@ -407,7 +407,7 @@ class RootwrapTestCase(testtools.TestCase): def test_ChainingRegExpFilter_not_match(self): filter_list = [filters.ChainingRegExpFilter('nice', 'root', - 'nice', '-?\d+'), + 'nice', r'-?\d+'), filters.CommandFilter('cat', 'root')] args_invalid = (['nice', '5', 'ls', '/a'], ['nice', '--5', 'cat', '/a'], diff --git a/test-requirements.txt b/test-requirements.txt index 3f5ae04..4a129a5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD testtools>=2.2.0 # MIT diff --git a/tox.ini b/tox.ini index 5f040e6..2c06ebb 100644 --- a/tox.ini +++ b/tox.ini @@ -50,9 +50,9 @@ commands = [flake8] # E731 skipped as assign a lambda expression - +# W504 line break after binary operator show-source = True -ignore = E731 +ignore = E731,W504 exclude = .tox,dist,doc,*.egg,build [testenv:benchmark]