diff --git a/tuf/interposition/updater.py b/tuf/interposition/updater.py index 5d7e148a..8c065479 100644 --- a/tuf/interposition/updater.py +++ b/tuf/interposition/updater.py @@ -132,10 +132,15 @@ def get_target_filepath(self, source_url): def open(self, url, data=None): filename, headers = self.retrieve(url, data=data) + # TUF should always open files in binary mode and remain transparent to the + # software updater. Opening files in text mode slightly alters the + # end-of-line characters and prevents binary files from properly loading on + # Windows. + # http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files # TODO: like tempfile, ensure file is deleted when closed? temporary_file = open(filename, 'rb') - # extend temporary_file with info(), getcode(), geturl() + # Extend temporary_file with info(), getcode(), geturl() # http://docs.python.org/2/library/urllib.html#urllib.urlopen response = urllib.addinfourl(temporary_file, headers, url, code=200)