summaryrefslogtreecommitdiffstats
path: root/peekaboo/queuing.py
diff options
context:
space:
mode:
authorMichael Weiser <michael.weiser@gmx.de>2019-04-08 13:58:32 +0000
committerMichael Weiser <michael.weiser@gmx.de>2019-04-08 13:58:32 +0000
commitb1148823a6365c89fae6f3077a33275c2fdc6fa1 (patch)
tree5158a8eafe024eb9fa4c150bf554453e7237c148 /peekaboo/queuing.py
parentaaf0e1ae4b6e10398530affc95d3d9305e38f39a (diff)
Avoid the str() constructor
Do not force string representations of stuff using the str() constructor because in almost all cases it is unnecessary and can cause funky encoding problems, most notably the notorious: UnicodeEncodeError: 'ascii' codec can't encode character '\ua000' in position 0: ordinal not in range(128) Instead, rely on python to convert the input object to the required target type, oblivious of the actual type until we do input/output.
Diffstat (limited to 'peekaboo/queuing.py')
-rw-r--r--peekaboo/queuing.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/peekaboo/queuing.py b/peekaboo/queuing.py
index ea21d97..c4cedd7 100644
--- a/peekaboo/queuing.py
+++ b/peekaboo/queuing.py
@@ -100,7 +100,7 @@ class JobQueue:
@raises Full: if the queue is full.
"""
sample_hash = sample.sha256sum
- sample_str = str(sample)
+ sample_str = "%s" % sample
duplicate = None
cluster_duplicate = None
resubmit = None
@@ -180,7 +180,7 @@ class JobQueue:
return False
if locked:
- sample_str = str(sample_duplicates[0])
+ sample_str = "%s" % sample_duplicates[0]
if self.duplicates.get(sample_hash) is not None:
logger.error("Possible backlog corruption for sample "
"%s! Please file a bug report. Trying to "
@@ -237,7 +237,7 @@ class JobQueue:
# submit all samples which have accumulated in the backlog
for s in self.duplicates[sample_hash]['duplicates']:
- submitted_duplicates.append(str(s))
+ submitted_duplicates.append("%s" % s)
self.jobs.put(s, True, self.queue_timeout)
sample = self.duplicates[sample_hash]['master']
@@ -246,7 +246,7 @@ class JobQueue:
except PeekabooDatabaseError as dberr:
logger.error(dberr)
- sample_str = str(sample)
+ sample_str = "%s" % sample
del self.duplicates[sample_hash]
logger.debug("Cleared sample %s from in-flight list" % sample_str)