--- a/WizardDataUriEncoder/DataUriEncoderWizardDialog.py Wed Dec 30 11:02:16 2020 +0100 +++ b/WizardDataUriEncoder/DataUriEncoderWizardDialog.py Sun Apr 25 16:57:01 2021 +0200 @@ -54,7 +54,7 @@ @param parent reference to the parent widget (QWidget) """ - super(DataUriEncoderWizardDialog, self).__init__(parent) + super().__init__(parent) self.setupUi(self) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) @@ -144,13 +144,14 @@ return try: - output = '"{0}{1}{2}{3}"'.format( - 'data:' if self.dataCheckBox.isChecked() else '', - mimetype if self.dataCheckBox.isChecked() else '', - ';charset=utf-8;base64,' if self.dataCheckBox.isChecked() - else '', - base64.b64encode(open(filepath, "rb").read()).decode() - ) + with open(filepath, "rb") as f: + output = '"{0}{1}{2}{3}"'.format( + 'data:' if self.dataCheckBox.isChecked() else '', + mimetype if self.dataCheckBox.isChecked() else '', + ';charset=utf-8;base64,' if self.dataCheckBox.isChecked() + else '', + base64.b64encode(f.read()).decode() + ) except OSError as err: E5MessageBox.critical( self,