Mercurial > hg
changeset 49208:2fe4efaa59af stable
worker: adapt _blockingreader to work around a python3.8.[0-1] bug (issue6444)
Python 3.8.0 is the latest I can load on Ubuntu 18.04, and I regularly hit the
TypeError because this function is missing. While it can be avoided by
disabling worker usage via config option, that's a bit obscure.
I'm limiting the function definition to the narrow range of affected pythons
because there were other bugs in this area that were worked around, that I don't
fully understand. See the bug report for discussions on why the narrow range,
and related commits working around other bugs.
Differential Revision: https://phab.mercurial-scm.org/D12627
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 May 2022 14:36:57 -0400 |
parents | 45e71954612c |
children | 2dd53a33aefa |
files | mercurial/worker.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/worker.py Wed May 04 13:53:12 2022 +0400 +++ b/mercurial/worker.py Tue May 17 14:36:57 2022 -0400 @@ -78,6 +78,21 @@ # _wrapped.readinto(), since that is unbuffered. The unpickler is fine # with just read() and readline(), so we don't need to implement it. + if (3, 8, 0) <= sys.version_info[:3] < (3, 8, 2): + + # This is required for python 3.8, prior to 3.8.2. See issue6444. + def readinto(self, b): + pos = 0 + size = len(b) + + while pos < size: + ret = self._wrapped.readinto(b[pos:]) + if not ret: + break + pos += ret + + return pos + def readline(self): return self._wrapped.readline()