Index: build/run_tests.py
===================================================================
--- build/run_tests.py	(revision 19344)
+++ build/run_tests.py	(working copy)
@@ -44,11 +44,11 @@
 
   def run(self, list):
     'Run all test programs given in LIST.'
-    self._open_log('w')
+    self._open_log('wb')
     failed = 0
     for prog in list:
       failed = self._run_test(prog) or failed
-    self._open_log('r')
+    self._open_log('rb')
     log_lines = self.log.readlines()
     skipped = filter(lambda x: x[:6] == 'SKIP: ', log_lines)
     if failed:
Index: subversion/tests/cmdline/authz_tests.py
===================================================================
--- subversion/tests/cmdline/authz_tests.py	(revision 19344)
+++ subversion/tests/cmdline/authz_tests.py	(working copy)
@@ -33,7 +33,7 @@
 def write_restrictive_svnserve_conf(repo_dir):
   "Create a restrictive authz file ( no anynomous access )."
   
-  fp = open(svntest.main.get_svnserve_conf_file_path(repo_dir), 'w')
+  fp = open(svntest.main.get_svnserve_conf_file_path(repo_dir), 'wb')
   fp.write("[general]\nanon-access = none\nauth-access = write\n"
            "password-db = passwd\nauthz-db = authz\n")
   fp.close()
@@ -60,7 +60,7 @@
   skip_test_when_no_authz_available()
   
   fp = open(svntest.main.get_authz_file_path(svntest.main.current_repo_dir),
-            'w')
+            'wb')
   fp.write("[/]\n\n[/A]\njrandom = rw\n")
   fp.close()
   
@@ -98,7 +98,7 @@
   skip_test_when_no_authz_available()
   
   fp = open(svntest.main.get_authz_file_path(svntest.main.current_repo_dir),
-            'w')
+            'wb')
   fp.write("[/]\n*=rw\n[/A/B]\n*=\n[/A/B/E]\njrandom = rw\n")
   fp.close()
   
Index: subversion/tests/cmdline/autoprop_tests.py
===================================================================
--- subversion/tests/cmdline/autoprop_tests.py	(revision 19344)
+++ subversion/tests/cmdline/autoprop_tests.py	(working copy)
@@ -75,7 +75,7 @@
 def create_test_file(dir, name):
   "create a test file"
 
-  fd = open(os.path.join(dir, name), 'w')
+  fd = open(os.path.join(dir, name), 'wb')
   fd.write('foo\nbar\nbaz\n')
   fd.close()
 
Index: subversion/tests/cmdline/basic_tests.py
===================================================================
--- subversion/tests/cmdline/basic_tests.py	(revision 19344)
+++ subversion/tests/cmdline/basic_tests.py	(working copy)
@@ -453,7 +453,7 @@
   # Make local mods to wc_backup by recreating mu and rho
   mu_path_backup = os.path.join(wc_backup, 'A', 'mu')
   rho_path_backup = os.path.join(wc_backup, 'A', 'D', 'G', 'rho')
-  fp_mu = open(mu_path_backup, 'w+')
+  fp_mu = open(mu_path_backup, 'wb+')
 
   # open in 'truncate to zero then write" mode
   backup_mu_text='This is the new line 1 in the backup copy of mu'
@@ -462,7 +462,7 @@
   fp_mu.write(backup_mu_text)
   fp_mu.close()
   
-  fp_rho = open(rho_path_backup, 'w+') # now open rho in write mode
+  fp_rho = open(rho_path_backup, 'wb+') # now open rho in write mode
   backup_rho_text='This is the new line 1 in the backup copy of rho'
   for x in range(2,11):
     backup_rho_text = backup_rho_text + '\nThis is line ' + `x` + ' in rho'
@@ -700,22 +700,22 @@
   svntest.actions.run_and_verify_status (wc_dir, expected_output)
 
   # Now, really make sure the contents are back to their original state.
-  fp = open(beta_path, 'r')
+  fp = open(beta_path, 'rb')
   lines = fp.readlines()
   if not ((len (lines) == 1) and (lines[0] == "This is the file 'beta'.\n")):
     print "Revert failed to restore original text."
     raise svntest.Failure
-  fp = open(iota_path, 'r')
+  fp = open(iota_path, 'rb')
   lines = fp.readlines()
   if not ((len (lines) == 1) and (lines[0] == "This is the file 'iota'.\n")):
     print "Revert failed to restore original text."
     raise svntest.Failure
-  fp = open(rho_path, 'r')
+  fp = open(rho_path, 'rb')
   lines = fp.readlines()
   if not ((len (lines) == 1) and (lines[0] == "This is the file 'rho'.\n")):
     print "Revert failed to restore original text."
     raise svntest.Failure
-  fp = open(zeta_path, 'r')
+  fp = open(zeta_path, 'rb')
   lines = fp.readlines()
   if not ((len (lines) == 1) and (lines[0] == "Added some text to 'zeta'.\n")):
     ### we should raise a less generic error here. which?
@@ -724,7 +724,7 @@
   # Finally, check that reverted file is not readonly
   os.remove(beta_path)
   svntest.actions.run_and_verify_svn(None, None, [], 'revert', beta_path)
-  if not (open(beta_path, 'rw+')):
+  if not (open(beta_path, 'rwb+')):
     raise svntest.Failure
 
   # Check that a directory scheduled to be added, but physically
@@ -892,7 +892,7 @@
 
 def verify_file_deleted(message, path):
   try:
-    open(path, 'r')
+    open(path, 'rb')
   except IOError:
     return
   if message is not None:
@@ -1440,8 +1440,8 @@
   foo_o_path = os.path.join(dir_path, 'foo.o')
 
   os.mkdir(dir_path, 0755)
-  open(foo_c_path, 'w')
-  open(foo_o_path, 'w')
+  open(foo_c_path, 'wb')
+  open(foo_o_path, 'wb')
 
   output, err = svntest.actions.run_and_verify_svn(
     "No output where some expected", SVNAnyOutput, [],
@@ -1470,7 +1470,7 @@
   svntest.actions.run_and_verify_svn(None, SVNAnyOutput, [],
                                      'mkdir', dir_path)
   svntest.main.run_svn(None, 'propset', 'svn:ignore', '*.lock', dir_path) 
-  open(file_path, 'w')
+  open(file_path, 'wb')
   svntest.actions.run_and_verify_svn(None, [], [],
                                      'add', '--force', dir_path)
 
@@ -1490,10 +1490,10 @@
   foo_rej_path = os.path.join(dir_path, 'foo.rej')
 
   os.mkdir(dir_path, 0755)
-  open(foo_c_path, 'w')
-  open(foo_o_path, 'w')
-  open(foo_lo_path, 'w')
-  open(foo_rej_path, 'w')
+  open(foo_c_path, 'wb')
+  open(foo_o_path, 'wb')
+  open(foo_lo_path, 'wb')
+  open(foo_rej_path, 'wb')
 
   output, err = svntest.actions.run_and_verify_svn(
     "No output where some expected", SVNAnyOutput, [],
Index: subversion/tests/cmdline/blame_tests.py
===================================================================
--- subversion/tests/cmdline/blame_tests.py	(revision 19344)
+++ subversion/tests/cmdline/blame_tests.py	(working copy)
@@ -248,7 +248,7 @@
   os.chdir(sbox.wc_dir)
   try:
     # Modify iota and commit it (r2).
-    open('iota', 'w').write("This is no longer the file 'iota'.\n")
+    open('iota', 'wb').write("This is no longer the file 'iota'.\n")
 
     expected_output = svntest.wc.State('.', {
       'iota' : Item(verb='Sending'),
Index: subversion/tests/cmdline/cat_tests.py
===================================================================
--- subversion/tests/cmdline/cat_tests.py	(revision 19344)
+++ subversion/tests/cmdline/cat_tests.py	(working copy)
@@ -91,7 +91,7 @@
   wc_dir = sbox.wc_dir
   dir_path = os.path.join(wc_dir, 'A', 'D')
   new_file_path = os.path.join(dir_path, 'new')
-  open(new_file_path, 'w')
+  open(new_file_path, 'wb')
   item_list = os.listdir(dir_path)
 
   # First we test running 'svn cat' on individual objects, expecting
Index: subversion/tests/cmdline/commit_tests.py
===================================================================
--- subversion/tests/cmdline/commit_tests.py	(revision 19344)
+++ subversion/tests/cmdline/commit_tests.py	(working copy)
@@ -1848,7 +1848,7 @@
                                         None, None, None, None, None, wc_dir)
 
   # Unversioned file still exists
-  fp = open(foo_path)
+  fp = open(foo_path, 'rb')
   if fp.read() != foo_contents:
     raise svntest.Failure
   fp.close()
Index: subversion/tests/cmdline/copy_tests.py
===================================================================
--- subversion/tests/cmdline/copy_tests.py	(revision 19344)
+++ subversion/tests/cmdline/copy_tests.py	(working copy)
@@ -1797,7 +1797,7 @@
   if os.path.exists(os.path.join(wc_dir, 'pi')):
     raise svntest.Failure
 
-  fp = open(os.path.join(wc_dir, 'rho'), 'r')
+  fp = open(os.path.join(wc_dir, 'rho'), 'rb')
   found_it = 0
   for line in fp.readlines():
     if re.match("^Second modification to rho.", line):
Index: subversion/tests/cmdline/diff_tests.py
===================================================================
--- subversion/tests/cmdline/diff_tests.py	(revision 19344)
+++ subversion/tests/cmdline/diff_tests.py	(working copy)
@@ -148,7 +148,7 @@
 
 def update_a_file():
   "update a file"
-  open(os.path.join('A', 'B', 'E', 'alpha'), 'w').write("new atext")
+  open(os.path.join('A', 'B', 'E', 'alpha'), 'wb').write("new atext")
   # svntest.main.file_append(, "new atext")
   return 0
 
@@ -271,9 +271,9 @@
 
 def update_three_files():
   "update three files"
-  open(os.path.join('A', 'D', 'gamma'), 'w').write("new gamma")
-  open(os.path.join('A', 'D', 'G', 'tau'), 'w').write("new tau")
-  open(os.path.join('A', 'D', 'H', 'psi'), 'w').write("new psi")
+  open(os.path.join('A', 'D', 'gamma'), 'wb').write("new gamma")
+  open(os.path.join('A', 'D', 'G', 'tau'), 'wb').write("new tau")
+  open(os.path.join('A', 'D', 'H', 'psi'), 'wb').write("new psi")
   return 0
 
 def check_update_three_files(diff_output):
@@ -700,12 +700,12 @@
   wc_dir = sbox.wc_dir
   
   # Add a binary file to the project.
-  fp = open(os.path.join(sys.path[0], "theta.bin"))
+  fp = open(os.path.join(sys.path[0], "theta.bin"), 'rb')
   theta_contents = fp.read()  # suck up contents of a test .png file
   fp.close()
 
   theta_path = os.path.join(wc_dir, 'A', 'theta')
-  fp = open(theta_path, 'w')
+  fp = open(theta_path, 'wb')
   fp.write(theta_contents)    # write png filedata into 'A/theta'
   fp.close()
   
@@ -1440,7 +1440,7 @@
 
 
   file_path = os.path.join(prefix_path, "test.txt")
-  f = open(file_path, "w")
+  f = open(file_path, "wb")
   f.write("Hello\nThere\nIota\n")
   f.close()
 
@@ -1457,7 +1457,7 @@
                                      'cp', '-m', 'log msg', prefix_url,
                                      other_prefix_url)
 
-  f = open(file_path, "w")
+  f = open(file_path, "wb")
   f.write("Hello\nWorld\nIota\n")
   f.close()
 
@@ -1491,7 +1491,7 @@
   try:
     pi_path = os.path.join('A', 'D', 'G', 'pi')
     pi2_path = os.path.join('A', 'D', 'pi2')
-    open(pi_path, 'w').write("new pi")
+    open(pi_path, 'wb').write("new pi")
 
     svntest.actions.run_and_verify_svn(None, None, [],
                                        'ci', '-m', 'log msg')
@@ -1572,7 +1572,7 @@
     svntest.main.run_svn(None, 'mv', os.path.join('A', 'D', 'G'),
                                      os.path.join('A', 'D', 'I'))
     # svntest.main.run_svn(None, 'ci', '-m', 'log_msg')
-    open(os.path.join('A', 'D', 'I', 'pi'), 'w').write("new pi")
+    open(os.path.join('A', 'D', 'I', 'pi'), 'wb').write("new pi")
 
     # Check a repos->wc diff
     diff_output, err_output = svntest.main.run_svn(None, 'diff',
@@ -1658,7 +1658,7 @@
                                      'Id Rev Date',
                                      iota_path)
 
-  fp = open(iota_path, 'w')
+  fp = open(iota_path, 'wb')
   fp.write("$Date$\n")
   fp.write("$Id$\n")
   fp.write("$Rev$\n")
@@ -1697,7 +1697,7 @@
 
   # Check fixed length keywords will show up
   # when the length of keyword has changed
-  fp = open(iota_path, 'w')
+  fp = open(iota_path, 'wb')
   fp.write("$Date$\n")
   fp.write("$Id$\n")
   fp.write("$Rev$\n")
@@ -2374,7 +2374,7 @@
 
     # Move, modify and commit a file
     svntest.main.run_svn(None, 'mv', oldfile, newfile)
-    open(newfile, 'w').write("new content\n")
+    open(newfile, 'wb').write("new content\n")
     svntest.actions.run_and_verify_svn(None, None, [], 'ci', '-m', '')
 
     # Check that a base->repos diff shows deleted and added lines.
Index: subversion/tests/cmdline/externals_tests.py
===================================================================
--- subversion/tests/cmdline/externals_tests.py	(revision 19344)
+++ subversion/tests/cmdline/externals_tests.py	(working copy)
@@ -249,7 +249,7 @@
     raise svntest.Failure("Probing for " + beta_path + " failed.")
 
   # Pick a file at random, make sure it has the expected contents.
-  fp = open(exdir_H_omega_path, 'r')
+  fp = open(exdir_H_omega_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1) and (lines[0] == "This is the file 'omega'.\n")):
     raise svntest.Failure("Unexpected contents for rev 1 of " +
@@ -555,7 +555,7 @@
   svntest.actions.run_and_verify_svn("", None, [], 'up', wc_dir)
 
   external_gamma_path = os.path.join(wc_dir, 'A', 'D', 'exdir_A', 'D', 'gamma')
-  fp = open(external_gamma_path, 'r')
+  fp = open(external_gamma_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 2)
           and (lines[0] == "This is the file 'gamma'.\n")
@@ -584,7 +584,7 @@
                                      'up', os.path.join(wc_dir, "A", "C"))
 
   external_rho_path = os.path.join(wc_dir, 'A', 'C', 'exdir_G', 'rho')
-  fp = open(external_rho_path, 'r')
+  fp = open(external_rho_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 2)
           and (lines[0] == "This is the file 'rho'.\n")
@@ -736,14 +736,14 @@
     raise svntest.Failure("Probing for " + beta_path + " failed.")
 
   # Pick some files, make sure their contents are as expected.
-  fp = open(exdir_G_pi_path, 'r')
+  fp = open(exdir_G_pi_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 2) \
           and (lines[0] == "This is the file 'pi'.\n") \
           and (lines[1] == "Added to pi in revision 3.\n")):
     raise svntest.Failure("Unexpected contents for rev 1 of " +
                           exdir_G_pi_path)
-  fp = open(exdir_H_omega_path, 'r')
+  fp = open(exdir_H_omega_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1) and (lines[0] == "This is the file 'omega'.\n")):
     raise svntest.Failure("Unexpected contents for rev 1 of " +
Index: subversion/tests/cmdline/getopt_tests.py
===================================================================
--- subversion/tests/cmdline/getopt_tests.py	(revision 19344)
+++ subversion/tests/cmdline/getopt_tests.py	(working copy)
@@ -44,8 +44,8 @@
   stdout_filename = os.path.join(getopt_output_dir, basename + '_stdout')
   stderr_filename = os.path.join(getopt_output_dir, basename + '_stderr')
 
-  exp_stdout = open(stdout_filename, 'r').readlines()
-  exp_stderr = open(stderr_filename, 'r').readlines()
+  exp_stdout = open(stdout_filename, 'rb').readlines()
+  exp_stderr = open(stderr_filename, 'rb').readlines()
 
   return exp_stdout, exp_stderr
 
Index: subversion/tests/cmdline/import_tests.py
===================================================================
--- subversion/tests/cmdline/import_tests.py	(revision 19344)
+++ subversion/tests/cmdline/import_tests.py	(working copy)
@@ -137,8 +137,8 @@
   foo_o_path = os.path.join(dir_path, 'foo.o')
 
   os.mkdir(dir_path, 0755)
-  open(foo_c_path, 'w')
-  open(foo_o_path, 'w')
+  open(foo_c_path, 'wb')
+  open(foo_o_path, 'wb')
 
   # import new dir into repository
   url = svntest.main.current_repo_url + '/dir'
@@ -204,10 +204,10 @@
   foo_rej_path = os.path.join(dir_path, 'foo.rej')
 
   os.mkdir(dir_path, 0755)
-  open(foo_c_path, 'w')
-  open(foo_o_path, 'w')
-  open(foo_lo_path, 'w')
-  open(foo_rej_path, 'w')
+  open(foo_c_path, 'wb')
+  open(foo_o_path, 'wb')
+  open(foo_lo_path, 'wb')
+  open(foo_rej_path, 'wb')
 
   # import new dir into repository
   url = svntest.main.current_repo_url + '/dir'
Index: subversion/tests/cmdline/merge_tests.py
===================================================================
--- subversion/tests/cmdline/merge_tests.py	(revision 19344)
+++ subversion/tests/cmdline/merge_tests.py	(working copy)
@@ -286,10 +286,10 @@
   other_rho_text = ""
   for x in range(1,10):
     other_rho_text = other_rho_text + 'Unobtrusive line ' + `x` + ' in rho\n'
-  fp = open(other_rho_path, "r")
+  fp = open(other_rho_path, "rb")
   current_other_rho_text = fp.read()
   fp.close()
-  fp = open(other_rho_path, 'w')
+  fp = open(other_rho_path, 'wb')
   fp.write(other_rho_text + current_other_rho_text)
   fp.close()
 
@@ -1355,12 +1355,12 @@
   wc_dir = sbox.wc_dir
 
   # Add a binary file to the project
-  fp = open(os.path.join(sys.path[0], "theta.bin"))
+  fp = open(os.path.join(sys.path[0], "theta.bin"), 'rb')
   theta_contents = fp.read()  # suck up contents of a test .png file
   fp.close()
 
   theta_path = os.path.join(wc_dir, 'A', 'theta')
-  fp = open(theta_path, 'w')
+  fp = open(theta_path, 'wb')
   fp.write(theta_contents)    # write png filedata into 'A/theta'
   fp.close()
   
@@ -1457,7 +1457,7 @@
   svntest.actions.run_and_verify_svn(None, None, [], 'update', wc_dir)
   
   new_file_path = os.path.join(wc_dir, 'A', 'B', 'E', 'newfile')
-  fp = open(new_file_path, 'w')
+  fp = open(new_file_path, 'wb')
   fp.write("newfile\n")
   fp.close()
 
@@ -1983,11 +1983,11 @@
   svntest.main.run_svn(None, 'mkdir', I_path)
 
   # Add a binary file to the common ancestry path
-  fp = open(os.path.join(sys.path[0], "theta.bin"))
+  fp = open(os.path.join(sys.path[0], "theta.bin"), 'rb')
   theta_contents = fp.read()
   fp.close()
   theta_I_path = os.path.join(wc_dir, 'I', 'theta')
-  fp = open(theta_I_path, 'w')
+  fp = open(theta_I_path, 'wb')
   fp.write(theta_contents)
   fp.close()
   svntest.main.run_svn(None, 'add', theta_I_path)
@@ -3103,7 +3103,7 @@
                                         None, None, None, None, None,
                                         wc_dir)
   # create new rho file
-  fp = open(rho_path, 'w')
+  fp = open(rho_path, 'wb')
   fp.write("new rho\n")
   fp.close()
 
@@ -3203,7 +3203,7 @@
                                         expected_status)
 
   # create new rho file
-  fp = open(rho_path, 'w')
+  fp = open(rho_path, 'wb')
   fp.write("new rho\n")
   fp.close()
 
Index: subversion/tests/cmdline/prop_tests.py
===================================================================
--- subversion/tests/cmdline/prop_tests.py	(revision 19344)
+++ subversion/tests/cmdline/prop_tests.py	(working copy)
@@ -1121,7 +1121,7 @@
                   ]
    
   # create new fs file
-  open(newfile_path, 'w').close()
+  open(newfile_path, 'wb').close()
   # Add it and set a property
   svntest.actions.run_and_verify_svn(None, file_add_output, [], 'add', newfile_path)
   svntest.actions.run_and_verify_svn(None, propset_output, [], 'propset',
@@ -1132,7 +1132,7 @@
   svntest.actions.run_and_verify_svn(None, file_rm_output, [],
                                      'rm', '--force', newfile_path)
   # recreate the file and add it again
-  open(newfile_path, 'w').close()
+  open(newfile_path, 'wb').close()
   svntest.actions.run_and_verify_svn(None, file_add_output, [], 'add', newfile_path)
 
   # Now there should be NO properties leftover...
Index: subversion/tests/cmdline/revert_tests.py
===================================================================
--- subversion/tests/cmdline/revert_tests.py	(revision 19344)
+++ subversion/tests/cmdline/revert_tests.py	(working copy)
@@ -245,7 +245,7 @@
   unexpanded_contents = "This is newfile: $Rev$.\n"
 
   # Put an unexpanded keyword into iota.
-  fp = open(newfile_path, 'w')
+  fp = open(newfile_path, 'wb')
   fp.write(unexpanded_contents)
   fp.close()
 
@@ -259,7 +259,7 @@
 
   # Verify that the keyword got expanded.
   def check_expanded(path):
-    fp = open(path, 'r')
+    fp = open(path, 'rb')
     lines = fp.readlines()
     fp.close()
     if lines[0] != "This is newfile: $Rev: 3 $.\n":
@@ -268,11 +268,11 @@
   check_expanded(newfile_path)
 
   # Now un-expand the keyword again.
-  fp = open(newfile_path, 'w')
+  fp = open(newfile_path, 'wb')
   fp.write(unexpanded_contents)
   fp.close()
 
-  fp = open(newfile_path, 'r')
+  fp = open(newfile_path, 'rb')
   lines = fp.readlines()
   fp.close()
 
@@ -401,7 +401,7 @@
                                         None, None, None, None, None,
                                         wc_dir)
   # create new rho file
-  fp = open(rho_path, 'w')
+  fp = open(rho_path, 'wb')
   fp.write("new rho\n")
   fp.close()
 
Index: subversion/tests/cmdline/schedule_tests.py
===================================================================
--- subversion/tests/cmdline/schedule_tests.py	(revision 19344)
+++ subversion/tests/cmdline/schedule_tests.py	(working copy)
@@ -173,7 +173,7 @@
       expected_out = ["*\n"]
     else:
       expected_out = []
-    f = open(fileName,"w")
+    f = open(fileName,"wb")
     f.close()
     os.chmod(fileName,perm)
     svntest.main.run_svn(None, 'add', fileName)
Index: subversion/tests/cmdline/svntest/entry.py
===================================================================
--- subversion/tests/cmdline/svntest/entry.py	(revision 19344)
+++ subversion/tests/cmdline/svntest/entry.py	(working copy)
@@ -77,7 +77,7 @@
   "Parse the entries file at PATH and return a list of svn_entry objects."
 
   entryparser = svn_entryparser() # make a parser instance
-  fp = open(path, 'r')
+  fp = open(path, 'rb')
   entryparser.parser.ParseFile(fp)
   fp.close()
   return entryparser.entry_dict
Index: subversion/tests/cmdline/svntest/main.py
===================================================================
--- subversion/tests/cmdline/svntest/main.py	(revision 19344)
+++ subversion/tests/cmdline/svntest/main.py	(working copy)
@@ -330,11 +330,11 @@
   if not os.path.isdir(cfgdir):
     os.makedirs(cfgdir)
 
-  fd = open(cfgfile_cfg, 'w')
+  fd = open(cfgfile_cfg, 'wb')
   fd.write(config_contents)
   fd.close()
 
-  fd = open(cfgfile_srv, 'w')
+  fd = open(cfgfile_srv, 'wb')
   fd.write(server_contents)
   fd.close()
 
@@ -404,7 +404,7 @@
 def file_append(path, new_text):
   "Append NEW_TEXT to file at PATH"
 
-  fp = open(path, 'a')  # open in (a)ppend mode
+  fp = open(path, 'ab')  # open in (a)ppend mode
   fp.write(new_text)
   fp.close()
 
@@ -412,7 +412,7 @@
 def file_write(path, new_text):
   "Replace contents of file at PATH with NEW_TEXT"
 
-  fp = open(path, 'w')  # open in (w)rite mode
+  fp = open(path, 'wb')  # open in (w)rite mode
   fp.write(new_text)
   fp.close()
 
Index: subversion/tests/cmdline/svntest/tree.py
===================================================================
--- subversion/tests/cmdline/svntest/tree.py	(revision 19344)
+++ subversion/tests/cmdline/svntest/tree.py	(working copy)
@@ -328,7 +328,7 @@
   if not os.path.isfile(path):
     return None
 
-  fp = open(path, 'r')
+  fp = open(path, 'rb')
   contents = fp.read()
   fp.close()
   return contents
Index: subversion/tests/cmdline/trans_tests.py
===================================================================
--- subversion/tests/cmdline/trans_tests.py	(revision 19344)
+++ subversion/tests/cmdline/trans_tests.py	(working copy)
@@ -265,7 +265,7 @@
                                          None, None, None, None, wc_dir)
 
   # Make sure the unexpanded URL keyword got expanded correctly.
-  fp = open(url_unexp_path, 'r')
+  fp = open(url_unexp_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
@@ -274,7 +274,7 @@
   fp.close()
 
   # Make sure the preexpanded URL keyword got reexpanded correctly.
-  fp = open(url_exp_path, 'r')
+  fp = open(url_exp_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
@@ -283,7 +283,7 @@
   fp.close()
 
   # Make sure the unexpanded Id keyword got expanded correctly.
-  fp = open(id_unexp_path, 'r')
+  fp = open(id_unexp_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$Id: id_unexp", lines[0]))):
@@ -292,7 +292,7 @@
   fp.close()
 
   # Make sure the preexpanded Id keyword got reexpanded correctly.
-  fp = open(id_exp_path, 'r')
+  fp = open(id_exp_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$Id: id_exp", lines[0]))):
@@ -315,7 +315,7 @@
     '$URL::x%sx$\n' % (' ' * len(url_expand_test_data))
   ]
 
-  fp = open(fixed_length_keywords_path, 'r')
+  fp = open(fixed_length_keywords_path, 'rb')
   actual_workingcopy_kw = fp.readlines()
   fp.close()
   check_keywords(actual_workingcopy_kw, kw_workingcopy, "working copy")
@@ -336,13 +336,13 @@
     ]
   
   fp = open(os.path.join(wc_dir, svntest.main.get_admin_name(),
-                         'text-base', 'fixed_length_keywords.svn-base'), 'r')
+                         'text-base', 'fixed_length_keywords.svn-base'), 'rb')
   actual_textbase_kw = fp.readlines()
   fp.close()
   check_keywords(actual_textbase_kw, kw_textbase, "text base")
   
   # Check the Id keyword for filename with spaces.
-  fp = open(id_with_space_path, 'r')
+  fp = open(id_with_space_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$Id: .*id with space", lines[0]))):
@@ -392,7 +392,7 @@
 
   # Replace contents of rho and set eol translation to 'native'
   rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
-  f = open(rho_path, "w")
+  f = open(rho_path, "wb")
   f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n")
   f.close()
   svntest.actions.run_and_verify_svn(None, None, [],
@@ -417,7 +417,7 @@
                                          rho_path)
 
   # Change rho again
-  f = open(rho_path, "w")
+  f = open(rho_path, "wb")
   f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n")
   f.close()
 
@@ -433,7 +433,7 @@
                                          rho_path)
 
   # Locally modify rho again.
-  f = open(rho_path, "w")
+  f = open(rho_path, "wb")
   f.write("1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n10\n")
   f.close()
 
@@ -568,7 +568,7 @@
 
   # Check keyword got expanded (and thus the mkdir, add, ps, commit
   # etc. worked)
-  fp = open(other_url_path, 'r')
+  fp = open(other_url_path, 'rb')
   lines = fp.readlines()
   if not ((len(lines) == 1)
           and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
@@ -717,7 +717,7 @@
                                       svntest.main.current_repo_url,
                                       other_wc_dir)
 
-  mu_other_contents = open(mu_other_path).read()
+  mu_other_contents = open(mu_other_path, 'rb').read()
   if mu_other_contents != "This is the file 'mu'.\n$Rev: 3 $":
     print "'%s' does not have the expected contents" % mu_other_path
     raise svntest.Failure
Index: subversion/tests/cmdline/update_tests.py
===================================================================
--- subversion/tests/cmdline/update_tests.py	(revision 19344)
+++ subversion/tests/cmdline/update_tests.py	(working copy)
@@ -62,7 +62,7 @@
       if contents is None:
         return
       else:
-        fp = open(os.path.join (wc_dir, node.path))
+        fp = open(os.path.join (wc_dir, node.path), 'rb')
         real_contents = fp.read()  # suck up contents of a test .png file
         fp.close()
         if real_contents == contents:
@@ -81,12 +81,12 @@
   wc_dir = sbox.wc_dir
 
   # Add a binary file to the project.
-  fp = open(os.path.join(sys.path[0], "theta.bin"))
+  fp = open(os.path.join(sys.path[0], "theta.bin"), 'rb')
   theta_contents = fp.read()  # suck up contents of a test .png file
   fp.close()
 
   theta_path = os.path.join(wc_dir, 'A', 'theta')
-  fp = open(theta_path, 'w')
+  fp = open(theta_path, 'wb')
   fp.write(theta_contents)    # write png filedata into 'A/theta'
   fp.close()
   
@@ -195,7 +195,7 @@
   wc_dir = sbox.wc_dir
 
   # Suck up contents of a test .png file.
-  fp = open(os.path.join(sys.path[0], "theta.bin"))
+  fp = open(os.path.join(sys.path[0], "theta.bin"), 'rb')
   theta_contents = fp.read()  
   fp.close()
 
@@ -211,11 +211,11 @@
 
   # Write our two files' contents out to disk, in A/theta and A/zeta.
   theta_path = os.path.join(wc_dir, 'A', 'theta')
-  fp = open(theta_path, 'w')
+  fp = open(theta_path, 'wb')
   fp.write(theta_contents)    
   fp.close()
   zeta_path = os.path.join(wc_dir, 'A', 'zeta')
-  fp = open(zeta_path, 'w')
+  fp = open(zeta_path, 'wb')
   fp.write(zeta_contents)
   fp.close()
 
Index: subversion/tests/libsvn_subr/target-test.py
===================================================================
--- subversion/tests/libsvn_subr/target-test.py	(revision 19344)
+++ subversion/tests/libsvn_subr/target-test.py	(working copy)
@@ -64,7 +64,7 @@
 os.mkdir('z/G')
 os.mkdir('z/G/H')
 os.mkdir('z/G/I')
-open('z/A/file', 'w').close()
+open('z/A/file', 'wb').close()
 
 def _run_test(cmdline):
   if sys.platform == 'win32':