From 9e63f0b303951da12dd4d96e9842b6c191763522 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 26 May 2012 12:00:29 -0400 Subject: [PATCH] Decode key returned from db into unicode. We get this error in cron: /usr/local/gerrit/scripts/update_gerrit_users.py:339: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if key.strip() not in db_keys: The stuff from Launchpad comes back as unicode, but the stuff from MySQL comes back as string, which makes the in comparison wonky. Perhaps we should upgrade the database to unicode properly as well... Change-Id: I5ef66763429ca490d799ebb5b030abdc4d5de67e --- modules/gerrit/files/scripts/update_gerrit_users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gerrit/files/scripts/update_gerrit_users.py b/modules/gerrit/files/scripts/update_gerrit_users.py index 15baaa9b79..8fd3a28aa2 100755 --- a/modules/gerrit/files/scripts/update_gerrit_users.py +++ b/modules/gerrit/files/scripts/update_gerrit_users.py @@ -335,7 +335,7 @@ for (username, user_details) in users.items(): cur.execute("""select ssh_public_key from account_ssh_keys where account_id = %s""", account_id) - db_keys = [r[0].strip() for r in cur.fetchall()] + db_keys = [r[0].strip().decode('utf-8') for r in cur.fetchall()] if key.strip() not in db_keys: cur.execute("""select max(seq)+1 from account_ssh_keys