[Python-checkins] cpython (merge default -> default): merge

brett.cannon python-checkins at python.org
Fri Jan 11 21:45:16 CET 2013


http://hg.python.org/cpython/rev/e3d47d5b9110
changeset:   81429:e3d47d5b9110
parent:      81428:b94f308e9b47
parent:      81426:c46dec051819
user:        Brett Cannon <brett at python.org>
date:        Fri Jan 11 15:43:34 2013 -0500
summary:
  merge

files:
  Doc/library/stat.rst     |   4 ---
  Lib/test/test_tools.py   |   1 +
  Tools/scripts/pindent.py |  32 +++++++++++++++++----------
  3 files changed, 21 insertions(+), 16 deletions(-)


diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst
--- a/Doc/library/stat.rst
+++ b/Doc/library/stat.rst
@@ -182,10 +182,6 @@
 
 Use of the functions above is more portable than use of the first set of flags:
 
-.. data:: S_IFMT
-
-   Bit mask for the file type bit fields.
-
 .. data:: S_IFSOCK
 
    Socket.
diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py
--- a/Lib/test/test_tools.py
+++ b/Lib/test/test_tools.py
@@ -59,6 +59,7 @@
         return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n'
 
     def test_selftest(self):
+        self.maxDiff = None
         with temp_dir() as directory:
             data_path = os.path.join(directory, '_test.py')
             with open(self.script) as f:
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -370,6 +370,23 @@
     return output.getvalue()
 # end def reformat_string
 
+def make_backup(filename):
+    import os, os.path
+    backup = filename + '~'
+    if os.path.lexists(backup):
+        try:
+            os.remove(backup)
+        except OSError:
+            print("Can't remove backup %r" % (backup,), file=sys.stderr)
+        # end try
+    # end if
+    try:
+        os.rename(filename, backup)
+    except OSError:
+        print("Can't rename %r to %r" % (filename, backup), file=sys.stderr)
+    # end try
+# end def make_backup
+
 def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
     with open(filename, 'r') as f:
         source = f.read()
@@ -377,10 +394,7 @@
     result = complete_string(source, stepsize, tabsize, expandtabs)
     if source == result: return 0
     # end if
-    import os
-    try: os.rename(filename, filename + '~')
-    except OSError: pass
-    # end try
+    make_backup(filename)
     with open(filename, 'w') as f:
         f.write(result)
     # end with
@@ -394,10 +408,7 @@
     result = delete_string(source, stepsize, tabsize, expandtabs)
     if source == result: return 0
     # end if
-    import os
-    try: os.rename(filename, filename + '~')
-    except OSError: pass
-    # end try
+    make_backup(filename)
     with open(filename, 'w') as f:
         f.write(result)
     # end with
@@ -411,10 +422,7 @@
     result = reformat_string(source, stepsize, tabsize, expandtabs)
     if source == result: return 0
     # end if
-    import os
-    try: os.rename(filename, filename + '~')
-    except OSError: pass
-    # end try
+    make_backup(filename)
     with open(filename, 'w') as f:
         f.write(result)
     # end with

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list