Skip to content

Commit ca158f4

Browse files
committed
Merge branch 'ld/p4-test-py3'
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 3b57758 + 1fb3fb4 commit ca158f4

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
@@ -207,9 +207,10 @@ marshal_dump () {
207207
cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
208208
import marshal
209209
import sys
210+
instream = getattr(sys.stdin, 'buffer', sys.stdin)
210211
for i in range($line):
211-
d = marshal.load(sys.stdin)
212-
print d['$what']
212+
d = marshal.load(instream)
213+
print(d[b'$what'].decode('utf-8'))
213214
EOF
214215
"$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
215216
}

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)