Skip to content

Commit 787a490

Browse files
committed
Merge branch 'ld/p4-test-py3' into HEAD
The test scripts for "git p4" (but not "git p4" implementation itself) has been updated so that they would work even on a system where the installed version of Python is python 3. * ld/p4-test-py3: git-p4 tests: time_in_seconds should use $PYTHON_PATH git-p4 tests: work with python3 as well as python2 git-p4 tests: cd to / before running python
2 parents d92347f + 1fb3fb4 commit 787a490

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

t/lib-git-p4.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ native_path() {
5050
# at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'
5151
# function could fix that but it is not in Python until 3.3.
5252
time_in_seconds() {
53-
python -c 'import time; print int(time.time())'
53+
(cd / && "$PYTHON_PATH" -c 'import time; print(int(time.time()))')
5454
}
5555

5656
# Try to pick a unique port: guess a large number, then hope
@@ -198,9 +198,10 @@ marshal_dump() {
198198
cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
199199
import marshal
200200
import sys
201+
instream = getattr(sys.stdin, 'buffer', sys.stdin)
201202
for i in range($line):
202-
d = marshal.load(sys.stdin)
203-
print d['$what']
203+
d = marshal.load(instream)
204+
print(d[b'$what'].decode('utf-8'))
204205
EOF
205206
"$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
206207
}

t/t9802-git-p4-filetype.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ build_gendouble() {
223223
import sys
224224
import struct
225225
226-
s = struct.pack(">LL18s",
226+
s = struct.pack(b">LL18s",
227227
0x00051607, # AppleDouble
228228
0x00020000, # version 2
229-
"" # pad to 26 bytes
229+
b"" # pad to 26 bytes
230230
)
231-
sys.stdout.write(s)
231+
getattr(sys.stdout, 'buffer', sys.stdout).write(s)
232232
EOF
233233
}
234234

0 commit comments

Comments
 (0)