Skip to content

Commit

Permalink
Merge pull request spesmilo#725 from rt121212121/f_issue_613_badaddre…
Browse files Browse the repository at this point in the history
…ssfile

Fix spesmilo#613. User selects binary file or file that contains more than ad…
  • Loading branch information
rt121212121 committed Jun 12, 2018
2 parents dfd2b76 + 32965e5 commit 2bedbd1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gui/qt/qrtextedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ def file_input(self):
fileName, __ = QFileDialog.getOpenFileName(self, 'select file')
if not fileName:
return
with open(fileName, "r", encoding='utf-8') as f:
data = f.read()
try:
with open(fileName, "r", encoding='utf-8') as f:
data = f.read()
except UnicodeDecodeError as reason:
self.show_critical(_("The selected file appears to be a binary file.") +"\n"+ _("Please ensure you only import text files."), title=_("Not a text file"))
return
self.setText(data)

def qr_input(self):
Expand Down

0 comments on commit 2bedbd1

Please sign in to comment.