summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-01-11 20:44:00 (GMT)
committerBrett Cannon <brett@python.org>2013-01-11 20:44:00 (GMT)
commited6b4c0020279c31b2c46107aac63b7a9170b907 (patch)
tree7a17ba6784e38b4993f12a960088d8845ffd6393
parenta9976b3e32b612e33dc9f6d8874a88d028de7424 (diff)
parentb4fb2e2aac17975d9c5775eb46d6dec4d0603406 (diff)
downloadcpython-ed6b4c0020279c31b2c46107aac63b7a9170b907.zip
cpython-ed6b4c0020279c31b2c46107aac63b7a9170b907.tar.gz
cpython-ed6b4c0020279c31b2c46107aac63b7a9170b907.tar.bz2
merge
-rw-r--r--Doc/library/stat.rst4
-rw-r--r--Lib/test/test_tools.py1
-rwxr-xr-xTools/scripts/pindent.py32
3 files changed, 21 insertions, 16 deletions
diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst
index f47f464..02513df 100644
--- a/Doc/library/stat.rst
+++ b/Doc/library/stat.rst
@@ -182,10 +182,6 @@ The variables below define the flags used in the :data:`ST_MODE` field.
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
index cfa5dbc..f971515 100644
--- a/Lib/test/test_tools.py
+++ b/Lib/test/test_tools.py
@@ -59,6 +59,7 @@ class PindentTests(unittest.TestCase):
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
index fd04c92..2872dc0 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -370,6 +370,23 @@ def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
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 os.error:
+ print("Can't remove backup %r" % (backup,), file=sys.stderr)
+ # end try
+ # end if
+ try:
+ os.rename(filename, backup)
+ except os.error:
+ 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 @@ def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
result = complete_string(source, stepsize, tabsize, expandtabs)
if source == result: return 0
# end if
- import os
- try: os.rename(filename, filename + '~')
- except os.error: pass
- # end try
+ make_backup(filename)
with open(filename, 'w') as f:
f.write(result)
# end with
@@ -394,10 +408,7 @@ def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = E
result = delete_string(source, stepsize, tabsize, expandtabs)
if source == result: return 0
# end if
- import os
- try: os.rename(filename, filename + '~')
- except os.error: pass
- # end try
+ make_backup(filename)
with open(filename, 'w') as f:
f.write(result)
# end with
@@ -411,10 +422,7 @@ def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
result = reformat_string(source, stepsize, tabsize, expandtabs)
if source == result: return 0
# end if
- import os
- try: os.rename(filename, filename + '~')
- except os.error: pass
- # end try
+ make_backup(filename)
with open(filename, 'w') as f:
f.write(result)
# end with