[PATCH] More detailed error output on corrupt UID mapping files
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon May 2 10:44:19 BST 2011
This function will need much more "robustifying", but the very least we
can do is to print the file name and line that are giving trouble.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
Chris, you might want to try this patch to see the exact file name and line
that are giving you trouble. Nicolas, I advocate this one for going into master :-)
Changelog.draft.rst | 1 +
offlineimap/folder/UIDMaps.py | 6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Changelog.draft.rst b/Changelog.draft.rst
index d0125b7..11d16ee 100644
--- a/Changelog.draft.rst
+++ b/Changelog.draft.rst
@@ -18,6 +18,7 @@ Changes
- no whitespace is stripped from comma-separated arguments passed via
the -f option.
+- give more detailed error when encountering a corrupt UID mapping file
Bug Fixes
---------
diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py
index 43b28e4..e87e21e 100644
--- a/offlineimap/folder/UIDMaps.py
+++ b/offlineimap/folder/UIDMaps.py
@@ -51,7 +51,11 @@ class MappingFolderMixIn:
line = file.readline()
if not len(line):
break
- line = line.strip()
+ try:
+ line = line.strip()
+ except ValueError:
+ raise Exception("Corrupt line '%s' in UID mapping file '%s'" \
+ %(line, mapfilename))
(str1, str2) = line.split(':')
loc = long(str1)
rem = long(str2)
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list