diff --git a/contrib/check-code.py b/contrib/check-code.py
index f6e9c731dd3f60f1fc98d9858efc331c30e1d846_Y29udHJpYi9jaGVjay1jb2RlLnB5..c6c9b83a1e8a6aa64c31563ac7a70072bfdf3727_Y29udHJpYi9jaGVjay1jb2RlLnB5 100755
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -54,7 +54,7 @@
     (r'head -c', "don't use 'head -c', use 'dd'"),
     (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
     (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
-    (r'printf.*\\\d\d\d', "don't use 'printf \NNN', use Python"),
+    (r'printf.*\\\d{1,3}', "don't use 'printf \NNN', use Python"),
     (r'printf.*\\x', "don't use printf \\x, use Python"),
     (r'\$\(.*\)', "don't use $(expr), use `expr`"),
     (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t
index f6e9c731dd3f60f1fc98d9858efc331c30e1d846_dGVzdHMvdGVzdC1kaWZmc3RhdC50..c6c9b83a1e8a6aa64c31563ac7a70072bfdf3727_dGVzdHMvdGVzdC1kaWZmc3RhdC50 100644
--- a/tests/test-diffstat.t
+++ b/tests/test-diffstat.t
@@ -35,7 +35,7 @@
 
   $ hg ci -m appenda
 
-  $ printf '\0' > c
+  >>> open("c", "wb").write("\0")
   $ touch d
   $ hg add c d
 
@@ -54,7 +54,7 @@
 
   $ hg ci -m createb
 
-  $ printf '\0' > "file with spaces"
+  >>> open("file with spaces", "wb").write("\0")
   $ hg add "file with spaces"
 
 Filename with spaces diffstat:
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
index f6e9c731dd3f60f1fc98d9858efc331c30e1d846_dGVzdHMvdGVzdC1rZXl3b3JkLnQ=..c6c9b83a1e8a6aa64c31563ac7a70072bfdf3727_dGVzdHMvdGVzdC1rZXl3b3JkLnQ= 100644
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -169,6 +169,6 @@
 
 hg status of kw-ignored binary file starting with '\1\n'
 
-  $ printf '\1\nfoo' > i
+  >>> open("i", "wb").write("\1\nfoo")
   $ hg -q commit -Am metasep i
   $ hg status
@@ -173,6 +173,6 @@
   $ hg -q commit -Am metasep i
   $ hg status
-  $ printf '\1\nbar' > i
+  >>> open("i", "wb").write("\1\nbar")
   $ hg status
   M i
   $ hg -q commit -m "modify metasep" i
diff --git a/tests/test-status.t b/tests/test-status.t
index f6e9c731dd3f60f1fc98d9858efc331c30e1d846_dGVzdHMvdGVzdC1zdGF0dXMudA==..c6c9b83a1e8a6aa64c31563ac7a70072bfdf3727_dGVzdHMvdGVzdC1zdGF0dXMudA== 100644
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -279,8 +279,8 @@
 
   $ hg init repo5
   $ cd repo5
-  $ printf '\1\nfoo' > 010a
+  >>> open("010a", "wb").write("\1\nfoo")
   $ hg ci -q -A -m 'initial checkin'
   $ hg status -A
   C 010a
 
@@ -283,8 +283,8 @@
   $ hg ci -q -A -m 'initial checkin'
   $ hg status -A
   C 010a
 
-  $ printf '\1\nbar' > 010a
+  >>> open("010a", "wb").write("\1\nbar")
   $ hg status -A
   M 010a
   $ hg ci -q -m 'modify 010a'
diff --git a/tests/test-subrepo-paths.t b/tests/test-subrepo-paths.t
index f6e9c731dd3f60f1fc98d9858efc331c30e1d846_dGVzdHMvdGVzdC1zdWJyZXBvLXBhdGhzLnQ=..c6c9b83a1e8a6aa64c31563ac7a70072bfdf3727_dGVzdHMvdGVzdC1zdWJyZXBvLXBhdGhzLnQ= 100644
--- a/tests/test-subrepo-paths.t
+++ b/tests/test-subrepo-paths.t
@@ -17,7 +17,7 @@
 hg debugsub with remapping
 
   $ echo '[subpaths]' >> .hg/hgrc
-  $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc
+  $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc # no-check-code
 
   $ hg debugsub
   path sub