{"thread":{"id":"42146","subject":"[PATCHv2 1/3] git-p4 tests: cd to / before running python","startedAt":"2016-04-26T07:50:58Z","lastAt":"2016-04-26T20:03:55Z","messageCount":6,"participants":["Luke Diamand","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"284514","messageId":"1461657061-7984-1-git-send-email-luke@diamand.org","threadId":"42146","inReplyTo":null,"subject":"[PATCHv2 0/3] git-p4: support python3 in the tests","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T07:50:58Z","receivedAt":"2016-04-26T07:50:58Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Updates to my patches to allow the git-p4 tests to work with python3.\n\nIncorporates suggestions from Junio to just switch to \"/\" and to\nuse $PYTHON_PATH.\n\nLuke Diamand (3):\n  git-p4 tests: cd to / before running python\n  git-p4 tests: work with python3 as well as python2\n  git-p4 tests: time_in_seconds should use $PYTHON_PATH\n\n t/lib-git-p4.sh            | 7 ++++---\n t/t9802-git-p4-filetype.sh | 6 +++---\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284511","messageId":"1461657061-7984-2-git-send-email-luke@diamand.org","threadId":"42146","inReplyTo":"1461657061-7984-1-git-send-email-luke@diamand.org","subject":"[PATCHv2 1/3] git-p4 tests: cd to / before running python","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T07:50:59Z","receivedAt":"2016-04-26T07:50:59Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"The python one-liner for getting the current time prints out\nerror messages if the current directory is deleted while it is\nrunning if using python3.\n\nAvoid these messages by switching to \"/\" before running it.\n\nThis problem does not arise if using python2.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/lib-git-p4.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex f9ae1d7..724bc43 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -50,7 +50,7 @@ native_path() {\n # at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'\n # function could fix that but it is not in Python until 3.3.\n time_in_seconds() {\n-\tpython -c 'import time; print int(time.time())'\n+\t(cd / && python -c 'import time; print(int(time.time()))')\n }\n \n # Try to pick a unique port: guess a large number, then hope\n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284512","messageId":"1461657061-7984-3-git-send-email-luke@diamand.org","threadId":"42146","inReplyTo":"1461657061-7984-1-git-send-email-luke@diamand.org","subject":"[PATCHv2 2/3] git-p4 tests: work with python3 as well as python2","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T07:51:00Z","receivedAt":"2016-04-26T07:51:00Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Update the git-p4 tests so that they work with both\nPython2 and Python3.\n\nWe have to be explicit about the difference between\nUnicode text strings (Python3 default) and raw binary\nstrings which will be exchanged with Perforce.\n\nAdditionally, print always takes braces in Python3.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/lib-git-p4.sh            | 5 +++--\n t/t9802-git-p4-filetype.sh | 6 +++---\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 724bc43..7393ee2 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -198,9 +198,10 @@ marshal_dump() {\n \tcat >\"$TRASH_DIRECTORY/marshal-dump.py\" <<-EOF &&\n \timport marshal\n \timport sys\n+\tinstream = getattr(sys.stdin, 'buffer', sys.stdin)\n \tfor i in range($line):\n-\t    d = marshal.load(sys.stdin)\n-\tprint d['$what']\n+\t    d = marshal.load(instream)\n+\tprint(d[b'$what'].decode('utf-8'))\n \tEOF\n \t\"$PYTHON_PATH\" \"$TRASH_DIRECTORY/marshal-dump.py\"\n }\ndiff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\nindex 66d3fc9..eb9a8ed 100755\n--- a/t/t9802-git-p4-filetype.sh\n+++ b/t/t9802-git-p4-filetype.sh\n@@ -223,12 +223,12 @@ build_gendouble() {\n \timport sys\n \timport struct\n \n-\ts = struct.pack(\">LL18s\",\n+\ts = struct.pack(b\">LL18s\",\n \t\t\t0x00051607,  # AppleDouble\n \t\t\t0x00020000,  # version 2\n-\t\t\t\"\"           # pad to 26 bytes\n+\t\t\tb\"\"          # pad to 26 bytes\n \t)\n-\tsys.stdout.write(s)\n+\tgetattr(sys.stdout, 'buffer', sys.stdout).write(s)\n \tEOF\n }\n \n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284513","messageId":"1461657061-7984-4-git-send-email-luke@diamand.org","threadId":"42146","inReplyTo":"1461657061-7984-1-git-send-email-luke@diamand.org","subject":"[PATCHv2 3/3] git-p4 tests: time_in_seconds should use $PYTHON_PATH","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T07:51:01Z","receivedAt":"2016-04-26T07:51:01Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"The time_in_seconds script should use $PYTHON_PATH, rather than\njust hard-coded python, so that users can override which version\ngets used, as is done for other python invocations.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/lib-git-p4.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 7393ee2..012d40e 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -50,7 +50,7 @@ native_path() {\n # at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'\n # function could fix that but it is not in Python until 3.3.\n time_in_seconds() {\n-\t(cd / && python -c 'import time; print(int(time.time()))')\n+\t(cd / && \"$PYTHON_PATH\" -c 'import time; print(int(time.time()))')\n }\n \n # Try to pick a unique port: guess a large number, then hope\n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284551","messageId":"xmqqpotcgt2l.fsf@gitster.mtv.corp.google.com","threadId":"42146","inReplyTo":"1461657061-7984-3-git-send-email-luke@diamand.org","subject":"Re: [PATCHv2 2/3] git-p4 tests: work with python3 as well as python2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-26T17:48:02Z","receivedAt":"2016-04-26T17:48:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> Update the git-p4 tests so that they work with both\n> Python2 and Python3.\n>\n> We have to be explicit about the difference between\n> Unicode text strings (Python3 default) and raw binary\n> strings which will be exchanged with Perforce.\n>\n> Additionally, print always takes braces in Python3.\n\ns/braces/parentheses/, I think (can locally tweak if you say so--in\nwhich case no need to resend).\n\n>\n> Signed-off-by: Luke Diamand <luke@diamand.org>\n> ---\n>  t/lib-git-p4.sh            | 5 +++--\n>  t/t9802-git-p4-filetype.sh | 6 +++---\n>  2 files changed, 6 insertions(+), 5 deletions(-)\n>\n> diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\n> index 724bc43..7393ee2 100644\n> --- a/t/lib-git-p4.sh\n> +++ b/t/lib-git-p4.sh\n> @@ -198,9 +198,10 @@ marshal_dump() {\n>  \tcat >\"$TRASH_DIRECTORY/marshal-dump.py\" <<-EOF &&\n>  \timport marshal\n>  \timport sys\n> +\tinstream = getattr(sys.stdin, 'buffer', sys.stdin)\n>  \tfor i in range($line):\n> -\t    d = marshal.load(sys.stdin)\n> -\tprint d['$what']\n> +\t    d = marshal.load(instream)\n> +\tprint(d[b'$what'].decode('utf-8'))\n>  \tEOF\n>  \t\"$PYTHON_PATH\" \"$TRASH_DIRECTORY/marshal-dump.py\"\n>  }\n> diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\n> index 66d3fc9..eb9a8ed 100755\n> --- a/t/t9802-git-p4-filetype.sh\n> +++ b/t/t9802-git-p4-filetype.sh\n> @@ -223,12 +223,12 @@ build_gendouble() {\n>  \timport sys\n>  \timport struct\n>  \n> -\ts = struct.pack(\">LL18s\",\n> +\ts = struct.pack(b\">LL18s\",\n>  \t\t\t0x00051607,  # AppleDouble\n>  \t\t\t0x00020000,  # version 2\n> -\t\t\t\"\"           # pad to 26 bytes\n> +\t\t\tb\"\"          # pad to 26 bytes\n>  \t)\n> -\tsys.stdout.write(s)\n> +\tgetattr(sys.stdout, 'buffer', sys.stdout).write(s)\n>  \tEOF\n>  }\n"},{"id":"284580","messageId":"CAE5ih79Ot8QBDcRatxxxoQdGKFXNtoQ-=j4uWqQ2g=KjLBNiHQ@mail.gmail.com","threadId":"42146","inReplyTo":"xmqqpotcgt2l.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCHv2 2/3] git-p4 tests: work with python3 as well as python2","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T20:03:55Z","receivedAt":"2016-04-26T20:03:55Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 26 April 2016 at 18:48, Junio C Hamano <gitster@pobox.com> wrote:\n> Luke Diamand <luke@diamand.org> writes:\n>\n>> Update the git-p4 tests so that they work with both\n>> Python2 and Python3.\n>>\n>> We have to be explicit about the difference between\n>> Unicode text strings (Python3 default) and raw binary\n>> strings which will be exchanged with Perforce.\n>>\n>> Additionally, print always takes braces in Python3.\n>\n> s/braces/parentheses/, I think (can locally tweak if you say so--in\n> which case no need to resend).\n\nPlease do so, thanks!\n\nLuke\n"}]}