filter_file, don't remove absent backup file (#5733)
I'm tracking down a problem with the perl package that's been generating this error: ``` OSError: OSError: [Errno 2] No such file or directory: '/blah/blah/blah/lib/5.24.1/x86_64-linux/Config.pm~' ``` The real problem is upstream, but it's being masked by an exception raised in `filter_file`s finally block. In my case, `backup` is `False`. The backup is created around line 127, the `re.sub()` calls fails (working on that), the `except` block fires and moves the backup file back, then the finally block tries to remove the non-existent backup file. This change just avoids trying to remove the non-existent file.
This commit is contained in:
parent
ffc4c31b82
commit
464e558aea
@ -136,7 +136,7 @@ def groupid_to_group(x):
|
||||
raise
|
||||
|
||||
finally:
|
||||
if not backup:
|
||||
if not backup and os.path.exists(backup_filename):
|
||||
os.remove(backup_filename)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user