[Commented On] D12628: worker: fix `_blockingreader.read()` to really block

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Fri May 20 13:19:36 UTC 2022


marmoute added a comment.


  In D12628#193389 <https://phab.mercurial-scm.org/D12628#193389>, @mjacob wrote:
  
  > `pickle.load()` requires that the passed file’s `read()` returns exactly as many bytes as was passed to its argument and `readinto()` fills the passed buffer completely; otherwise it raises the “pickle data was truncated” error or `EOFError` if unambiguously encountering EOF.
  > For buffered streams this is the case if they are non-interactive and EOF is not reached (which we handle specifically) (according to https://docs.python.org/3/library/io.html#io.BufferedIOBase.read).
  > However, we can’t use buffered streams because the selector checks whether the unbuffered stream is readable while we need to check that the stream passed to `pickle.load()` is readable (the bug resulting from this was fixed in 12491abf93bd87b057cb6826e36606afa1cee88a <https://phab.mercurial-scm.org/rHG12491abf93bd87b057cb6826e36606afa1cee88a>).
  > `_blockingreader` wraps the unbuffered stream to meet the expectations of `pickle.load()` while not reading too much data to create the problem described in the previous paragraph.
  
  Interresting. Can I convince you to send a patch adding this explanation to the class docstring ? (and maybe fixing the class name)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D12628/new/

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

To: mharbison72, #hg-reviewers, mjacob
Cc: marmoute, mjacob, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220520/38ae843c/attachment-0002.html>


More information about the Mercurial-patches mailing list