diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -24,6 +24,7 @@ test-bisect3.t
 test-blackbox.t
 test-bookmarks-current.t
 test-bookmarks-merge.t
+test-bookmarks-pushpull.t
 test-bookmarks-rebase.t
 test-bookmarks-strip.t
 test-bookmarks.t
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -1034,7 +1034,8 @@ Pushing a really long bookmark should wo
 ===============================================
 
 #if b2-binary
-  >>> open('longname', 'w').write('wat' * 100)
+  >>> with open('longname', 'w') as f:
+  ...     f.write('wat' * 100) and None
   $ hg book `cat longname`
   $ hg push -B `cat longname` ../unchanged-b
   pushing to ../unchanged-b