On Python3 importing a patch from an URL for which the content is greater than 8096 creates sometimes wrong result. The content of some lines modified is duplicated. I traced the bug to the HTTPResponse.readline method in combination with HTTPResponse.readinto. The readline method append to the chunks the content of the _rbuf then there is a loop that call _raw_read which on Python3 call readinto. But the readinto version in mercurial append again the _rbuf content. So this creates the duplicate content. This does not happen in Python2 because _raw_read does not call readinto. I do not know what is the best solution: - not append _rbuf content in readinto - not fill buffer with _rbuf in readline on Python3 (it is needed on Python2).
Created attachment 2076 [details] Fill chunks only when readinto is not used Here is my proposal.
This looks quite serious. Can you look into sending you patch through our official means: https://www.mercurial-scm.org/wiki/ContributingChanges
Bug marked urgent for 10 days, bumping
(In reply to Pierre-Yves David from comment #2) https://phab.mercurial-scm.org/D8859
Fixed by https://mercurial-scm.org/repo/hg/rev/49f8ba4febec Cédric Krier <ced@b2ck.com> keepalive: Do not append _rbuf if _raw_readinto exists (issue6356) The readline method append to the chunks the content of the _rbuf then there is a loop that call _raw_read which on Python3 call readinto. But the readinto version in mercurial append again the _rbuf content. So this creates the duplicate content. This does not happen in Python2 because _raw_read does not call readinto. Differential Revision: https://phab.mercurial-scm.org/D8859 (please test the fix)
Bug was set to TESTING for 7 days, resolving