Skip to content

Commit

Permalink
Improve exception on unicode decode failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris AtLee committed May 10, 2010
1 parent a6839b6 commit 684ba07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions buildbot/db/schema/v1.py
Expand Up @@ -280,11 +280,15 @@ def remove_none(x):
return x.decode("utf8")
else:
return x
values = tuple(remove_none(x) for x in
(change.number, change.who,
change.comments, change.isdir,
change.branch, change.revision, change.revlink,
change.when, change.category))
try:
values = tuple(remove_none(x) for x in
(change.number, change.who,
change.comments, change.isdir,
change.branch, change.revision, change.revlink,
change.when, change.category))
except UnicodeDecodeError:
raise UnicodeError("Trying to import change data as UTF-8 failed. Please look at contrib/fix_changes_pickle_encoding.py")

q = util.sql_insert(self.dbapi, 'changes',
"""changeid author comments is_dir branch revision
revlink when_timestamp category""".split())
Expand Down
2 changes: 1 addition & 1 deletion buildbot/test/regressions/test_import_unicode_changes.py
Expand Up @@ -55,7 +55,7 @@ def testNonUnicodeChange(self):
"changes.pck"), "w"))

sm = manager.DBSchemaManager(self.spec, self.basedir)
self.assertRaises(UnicodeDecodeError, sm.upgrade)
self.assertRaises(UnicodeError, sm.upgrade)

def testAsciiChange(self):
# Create changes.pck
Expand Down

0 comments on commit 684ba07

Please sign in to comment.