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

Yuya Nishihara yuya at tcha.org
Tue May 17 09:24:21 EDT 2016


On Mon, 16 May 2016 10:56:59 -0700, timeless wrote:
> 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
> -

That's because you use different io objects without flushing. The following
code works for me, thought it is ugly.

            sys.stdout.flush()
            sys.stdout.buffer.write(data)
            sys.stdout.buffer.flush()

I don't know the Python3 way, but we'd probably better use either text or
binary io consistently.


More information about the Mercurial-devel mailing list