* src/GrampsDbUtils/_GedcomStageOne.py: empty gedcom gives error message, not crash



svn: r8991
This commit is contained in:
Benny Malengier
2007-09-19 07:40:55 +00:00
parent 9328d1fb4f
commit 0c1abd5a54
3 changed files with 8 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ LOG = logging.getLogger(".GedcomImport")
BAD_UTF16 = _("Your GEDCOM file is corrupted. "
"The file appears to be encoded using the UTF16 "
"character set, but is missing the BOM marker.")
EMPTY_GED = _("Your GEDCOM file is empty.")
#-------------------------------------------------------------------------
#
@@ -125,6 +126,8 @@ class StageOne:
self.enc = "UTF16"
input_file.seek(0)
return codecs.EncodedFile(input_file, 'utf8', 'utf16')
elif not line :
raise Errors.GedcomError(EMPTY_GED)
elif line[0] == "\x00" or line[1] == "\x00":
raise Errors.GedcomError(BAD_UTF16)
else: