Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c743a62

Browse files
committed
Python 2 compatibility
1 parent 2fc05d5 commit c743a62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/dviread.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,9 @@ def __init__(self, filename=None):
12021202
while not ok:
12031203
self.connection = sqlite3.connect(
12041204
filename, isolation_level="DEFERRED")
1205-
if _log.isEnabledFor(logging.DEBUG):
1205+
if (_log.isEnabledFor(logging.DEBUG) and
1206+
hasattr(self.connection, 'set_trace_callback')):
1207+
# set_trace_callback is a Python 3 feature
12061208
def debug_sql(sql):
12071209
_log.debug(' '.join(sql.splitlines()).strip())
12081210
self.connection.set_trace_callback(debug_sql)
@@ -1406,7 +1408,7 @@ def dvi_font_sync_metrics(self, dvifont, connection):
14061408
# make the width data very compressible.
14071409
widths = struct.pack('<{}I'.format(len(dvifont.widths)),
14081410
*dvifont.widths)
1409-
widths = zlib.compress(widths, 9)
1411+
widths = buffer(zlib.compress(widths, 9))
14101412
connection.execute("""
14111413
INSERT INTO dvi_font_metrics (id, scale, widths)
14121414
SELECT id, :scale, :widths FROM dvi_font WHERE texname=:texname

0 commit comments

Comments
 (0)