[PATCH 6 of 7] get-with-headers: handle python3 bytes in stdout

timeless timeless at gmail.com
Mon May 16 13:56:59 EDT 2016


These tests fail w/o that change:
test-hgweb-bundle.t
test-hgweb-removed.t
test-hgweb-empty.t
test-hgweb-raw.t
test-hgweb-descend-empties.t
test-hgwebdirsym.t
test-hgweb-filelog.t
test-mq-qclone-http.t
test-hgweb-diffs.t
test-share.t
test-hgweb-symrev.t
test-hgwebdir.t
test-obsolete.t
test-largefiles.t

I think the answer is that even though the py2 print statement isn't
documented to call flush, it must be calling flush.

The command I'm using:
./run-tests.py --with-hg=~/bin/hg -j120 $X

(Where X is that set of files)

I guess that change should be split into a distinct commit.

Sample failure output:
--- test-hgweb-bundle.t
+++ test-hgweb-bundle.t.err
@@ -28,10 +28,10 @@
 Ensure we're serving from the bundle

   $ (get-with-headers.py localhost:$HGPORT 'file/tip/?style=raw')
-  200 Script output follows
-

   -rw-r--r-- 2 bar
   -rw-r--r-- 2 foo


+  200 Script output follows
+

ERROR: test-hgweb-bundle.t output changed

On Mon, May 16, 2016 at 7:33 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Wed, 11 May 2016 05:20:28 +0000, timeless wrote:
>> # HG changeset patch
>> # User timeless <timeless at mozdev.org>
>> # Date 1462561643 0
>> #      Fri May 06 19:07:23 2016 +0000
>> # Node ID 6849a6b26ea35775c142b78802b6b943dd2adf68
>> # Parent  67542cf802e8669a1c954c3066f468fe3ae6ba0e
>> # EXP-Topic runtests
>> # Available At bb://timeless/mercurial-crew
>> #              hg pull bb://timeless/mercurial-crew -r 6849a6b26ea3
>> get-with-headers: handle python3 bytes in stdout
>>
>> diff -r 67542cf802e8 -r 6849a6b26ea3 tests/get-with-headers.py
>> --- a/tests/get-with-headers.py       Fri May 06 19:06:05 2016 +0000
>> +++ b/tests/get-with-headers.py       Fri May 06 19:07:23 2016 +0000
>> @@ -17,6 +17,17 @@
>>  except ImportError:
>>      pass
>>
>> +try:
>> +    stdout = sys.stdout.buffer
>> +except AttributeError:
>> +    stdout = sys.stdout
>> +
>> +if sys.version_info[0] < 3:
>> +    sprint = print
>> +else:
>> +    def sprint(*s):
>> +        print(*s, file=sys.stdout, flush=True)
>
> Why do flush() only on Python 3 ?
>
> The commit message explains why we need "stdout = sys.stdout.buffer", but
> it says nothing about sprint().
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list