Patchwork D12627: worker: adapt _blockingreader to work around a python3.8.[0-1] bug (issue6444)

login
register
mail settings
Submitter phabricator
Date May 17, 2022, 7:33 p.m.
Message ID <differential-rev-PHID-DREV-zx57y7g43ekhi5iggadw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50980/
State New
Headers show

Comments

phabricator - May 17, 2022, 7:33 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D12627

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -78,6 +78,14 @@ 
         # _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):
+                data = self._wrapped.readall()
+                b[:] = data
+                return len(data)
+
         def readline(self):
             return self._wrapped.readline()