git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Luke Diamand <luke@diamand.org>
Cc: git@vger.kernel.org, Lars Schneider <larsxschneider@gmail.com>,
	Vitor Antunes <vitor.hda@gmail.com>,
	Sam Hocevar <sam@hocevar.net>
Subject: Re: [PATCHv2 2/3] git-p4 tests: work with python3 as well as python2
Date: Tue, 26 Apr 2016 10:48:02 -0700	[thread overview]
Message-ID: <xmqqpotcgt2l.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1461657061-7984-3-git-send-email-luke@diamand.org> (Luke Diamand's message of "Tue, 26 Apr 2016 08:51:00 +0100")

Luke Diamand <luke@diamand.org> writes:

> Update the git-p4 tests so that they work with both
> Python2 and Python3.
>
> We have to be explicit about the difference between
> Unicode text strings (Python3 default) and raw binary
> strings which will be exchanged with Perforce.
>
> Additionally, print always takes braces in Python3.

s/braces/parentheses/, I think (can locally tweak if you say so--in
which case no need to resend).

>
> Signed-off-by: Luke Diamand <luke@diamand.org>
> ---
>  t/lib-git-p4.sh            | 5 +++--
>  t/t9802-git-p4-filetype.sh | 6 +++---
>  2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
> index 724bc43..7393ee2 100644
> --- a/t/lib-git-p4.sh
> +++ b/t/lib-git-p4.sh
> @@ -198,9 +198,10 @@ marshal_dump() {
>  	cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
>  	import marshal
>  	import sys
> +	instream = getattr(sys.stdin, 'buffer', sys.stdin)
>  	for i in range($line):
> -	    d = marshal.load(sys.stdin)
> -	print d['$what']
> +	    d = marshal.load(instream)
> +	print(d[b'$what'].decode('utf-8'))
>  	EOF
>  	"$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
>  }
> diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
> index 66d3fc9..eb9a8ed 100755
> --- a/t/t9802-git-p4-filetype.sh
> +++ b/t/t9802-git-p4-filetype.sh
> @@ -223,12 +223,12 @@ build_gendouble() {
>  	import sys
>  	import struct
>  
> -	s = struct.pack(">LL18s",
> +	s = struct.pack(b">LL18s",
>  			0x00051607,  # AppleDouble
>  			0x00020000,  # version 2
> -			""           # pad to 26 bytes
> +			b""          # pad to 26 bytes
>  	)
> -	sys.stdout.write(s)
> +	getattr(sys.stdout, 'buffer', sys.stdout).write(s)
>  	EOF
>  }

  reply	other threads:[~2016-04-26 17:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  7:50 [PATCHv2 0/3] git-p4: support python3 in the tests Luke Diamand
2016-04-26  7:50 ` [PATCHv2 1/3] git-p4 tests: cd to / before running python Luke Diamand
2016-04-26  7:51 ` [PATCHv2 2/3] git-p4 tests: work with python3 as well as python2 Luke Diamand
2016-04-26 17:48   ` Junio C Hamano [this message]
2016-04-26 20:03     ` Luke Diamand
2016-04-26  7:51 ` [PATCHv2 3/3] git-p4 tests: time_in_seconds should use $PYTHON_PATH Luke Diamand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpotcgt2l.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=larsxschneider@gmail.com \
    --cc=luke@diamand.org \
    --cc=sam@hocevar.net \
    --cc=vitor.hda@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).