From cb4080d565ddb1232674affb051944522ca37aee Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 30 Jul 2019 15:35:00 -0400 Subject: A little more discipline for blob converters --- coverage/sqldata.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'coverage') diff --git a/coverage/sqldata.py b/coverage/sqldata.py index a37c9ae5..4a00414d 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -86,14 +86,20 @@ CREATE TABLE tracer ( """ if env.PY2: - def to_blob(bytes): - return buffer(bytes) + def to_blob(b): + """Convert a bytestring into a type SQLite will accept for a blob.""" + return buffer(b) # pylint: disable=undefined-variable + def from_blob(blob): + """Convert a blob read from SQLite into a bytestring.""" return bytes(blob) else: - def to_blob(bytes): - return bytes + def to_blob(b): + """Convert a bytestring into a type SQLite will accept for a blob.""" + return b + def from_blob(blob): + """Convert a blob read from SQLite into a bytestring.""" return blob @@ -507,7 +513,8 @@ class CoverageData(SimpleReprMixin): 'inner join context on context.id = line_map.context_id' ) lines = { - (files[path], context): from_blob(numbits) for (path, context, numbits) in cur + (files[path], context): from_blob(numbits) + for (path, context, numbits) in cur } cur.close() -- cgit v1.2.1