D9452: run-tests: fix a socket context manager for py2
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Sun Nov 29 04:00:56 UTC 2020
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
I broke this in e1404a75cddd <https://phab.mercurial-scm.org/rHGe1404a75cddd453d1c75c80087ae2d054f8c9265>, because the socket class lacks `__exit__` on py2.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9452
AFFECTED FILES
tests/run-tests.py
CHANGE DETAILS
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -47,6 +47,7 @@
import argparse
import collections
+import contextlib
import difflib
import distutils.version as version
import errno
@@ -255,7 +256,7 @@
else:
family = socket.AF_INET
try:
- with socket.socket(family, socket.SOCK_STREAM) as s:
+ with contextlib.closing(socket.socket(family, socket.SOCK_STREAM)) as s:
s.bind(('localhost', port))
return True
except socket.error as exc:
To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list