diff --git a/tests/test-log-linerange.t b/tests/test-log-linerange.t
index 9645c2a2bc2acceb2e61bc15103ecd686ee09963_dGVzdHMvdGVzdC1sb2ctbGluZXJhbmdlLnQ=..af924308110abc43e5bb499f1edc665b8f72015f_dGVzdHMvdGVzdC1sb2ctbGluZXJhbmdlLnQ= 100644
--- a/tests/test-log-linerange.t
+++ b/tests/test-log-linerange.t
@@ -800,7 +800,7 @@
 Binary files work but without diff hunks filtering.
 (Checking w/ and w/o diff.git option.)
 
-  >>> open('binary', 'w').write('this\nis\na\nbinary\0')
+  >>> open('binary', 'wb').write('this\nis\na\nbinary\0')
   $ hg add binary
   $ hg ci -m 'add a binary file' --quiet
   $ hg log -f -L binary,1:2 -p