Patchwork [1,of,2,STABLE] selectors2: backport minimal fix of timeout handling from 2.0.1

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 3, 2018, 1:04 p.m.
Message ID <d1bda397df7330fb192a.1543842283@mimosa>
Download mbox | patch
Permalink /patch/36920/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 3, 2018, 1:04 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1543840279 -32400
#      Mon Dec 03 21:31:19 2018 +0900
# Branch stable
# Node ID d1bda397df7330fb192a94dcb0801928a2492074
# Parent  d9fc51f77cc558f4a687f51e5ebd7d424688f917
selectors2: backport minimal fix of timeout handling from 2.0.1

The original code would raise TypeError since OSError() doesn't support
keyword arguments.

We can't simply import the selectors 2.0.1, which still spawns "uname -p"
through platform.system(). We could switch to the unreleased version, but
I decided to not right now to minimize the change.

Patch

diff --git a/mercurial/thirdparty/selectors2.py b/mercurial/thirdparty/selectors2.py
--- a/mercurial/thirdparty/selectors2.py
+++ b/mercurial/thirdparty/selectors2.py
@@ -708,7 +708,7 @@  else:
                     if expires is not None:
                         current_time = monotonic()
                         if current_time > expires:
-                            raise OSError(errno=errno.ETIMEDOUT)
+                            raise OSError(errno.ETIMEDOUT, 'Connection timed out')
                         if recalc_timeout:
                             if "timeout" in kwargs:
                                 kwargs["timeout"] = expires - current_time