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

Skip to content

Commit cc071ff

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/dviread.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
if six.PY3:
4949
def ord(x):
5050
return x
51+
buffer = memoryview
5152

5253
_log = logging.getLogger(__name__)
5354

@@ -1202,7 +1203,9 @@ def __init__(self, filename=None):
12021203
while not ok:
12031204
self.connection = sqlite3.connect(
12041205
filename, isolation_level="DEFERRED")
1205-
if _log.isEnabledFor(logging.DEBUG):
1206+
if (_log.isEnabledFor(logging.DEBUG) and
1207+
hasattr(self.connection, 'set_trace_callback')):
1208+
# set_trace_callback is a Python 3 feature
12061209
def debug_sql(sql):
12071210
_log.debug(' '.join(sql.splitlines()).strip())
12081211
self.connection.set_trace_callback(debug_sql)
@@ -1406,7 +1409,7 @@ def dvi_font_sync_metrics(self, dvifont, connection):
14061409
# make the width data very compressible.
14071410
widths = struct.pack('<{}I'.format(len(dvifont.widths)),
14081411
*dvifont.widths)
1409-
widths = zlib.compress(widths, 9)
1412+
widths = buffer(zlib.compress(widths, 9))
14101413
connection.execute("""
14111414
INSERT INTO dvi_font_metrics (id, scale, widths)
14121415
SELECT id, :scale, :widths FROM dvi_font WHERE texname=:texname

0 commit comments

Comments
 (0)