1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

Replace Some Platform-Specific Line Separation (#7203)

os.linesep isn't supposed to be used when writing to files opened in
text mode, where '\n' is escaped to the platform-specific ASCII
sequence.  For example, on Windows, os.linesep is '\r\n' and in text
mode is escaped to ASCII sequence CR CR LF rather than just CR LF.
This is also true for the default logger and IDisplay notifications.

Replacing os.linesep with '\n' ensures the right sequence is escaped.

Resolves: 6899
This commit is contained in:
dkp
2019-06-28 22:06:52 +02:00
committed by Brad Warren
parent 1c75b6dacd
commit 4fc30f2ecb
3 changed files with 7 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
### Fixed
*
* Replace some unnecessary platform-specific line separation.
More details about these changes can be found on our GitHub repo.

View File

@@ -114,7 +114,7 @@ class FileDisplay(object):
message = _wrap_lines(message)
self.outfile.write(
"{line}{frame}{line}{msg}{line}{frame}{line}".format(
line=os.linesep, frame=SIDE_FRAME, msg=message))
line='\n', frame=SIDE_FRAME, msg=message))
self.outfile.flush()
if pause:
if self._can_interact(force_interactive):

View File

@@ -178,10 +178,10 @@ class Reverter(object):
for path in filepaths:
output.append(" {0}".format(path))
output.append(os.linesep)
output.append('\n')
zope.component.getUtility(interfaces.IDisplay).notification(
os.linesep.join(output), force_interactive=True, pause=False)
'\n'.join(output), force_interactive=True, pause=False)
return None
def add_to_temp_checkpoint(self, save_files, save_notes):
@@ -497,9 +497,9 @@ class Reverter(object):
os.remove(path)
else:
logger.warning(
"File: %s - Could not be found to be deleted %s - "
"Certbot probably shut down unexpectedly",
os.linesep, path)
"File: %s - Could not be found to be deleted\n"
" - Certbot probably shut down unexpectedly",
path)
except (IOError, OSError):
logger.critical(
"Unable to remove filepaths contained within %s", file_list)