From a1d633dc5fd3d323ca719c6c2e9b286660384ced Mon Sep 17 00:00:00 2001 From: Kashiko Koibumi Date: Fri, 31 May 2024 02:32:58 +0900 Subject: [PATCH] workaround to invalid tag type tag sometimes contains str type, which causes an error in Python3. --- src/storage/sqlite.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 9d1f32b0..0064262d 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -1,6 +1,7 @@ """ Sqlite Inventory """ +import six import sqlite3 import time from threading import RLock @@ -110,7 +111,10 @@ class SqliteInventory(InventoryStorage): # always use the inventoryLock OUTSIDE of the sqlLock. with SqlBulkExecute() as sql: for objectHash, value in self._inventory.items(): - value = [value[0], value[1], sqlite3.Binary(value[2]), value[3], sqlite3.Binary(value[4])] + tag = value[4] + if six.PY3 and isinstance(tag, str): + tag = tag.encode("utf-8", "replace") + value = [value[0], value[1], sqlite3.Binary(value[2]), value[3], sqlite3.Binary(tag)] sql.execute( 'INSERT INTO inventory VALUES (?, ?, ?, ?, ?, ?)', sqlite3.Binary(objectHash), *value)