Package: matplotlib
Version: 0.90.1-4
Severity: important
An API changed between Python 2.4 and Python 2.5 such that matplotlib
0.90.1 can no longer output PDF files using its (non-Cairo) PDF backend.
There is a matplotlib bug report for this issue here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1738494&group_id=80706&atid=560720
To replicate run the attached Python script:
> python pdf_broken.py
Traceback (most recent call last):
File "pdf_broken.py", line 7, in <module>
savefig("test")
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line
796, in savefig
return fig.savefig(*args, **kwargs)
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/figure.py", line
759, in savefig
self.canvas.print_figure(*args, **kwargs)
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 1395, in print_figure
file.close()
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 401, in close
self.writeFonts()
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 456, in writeFonts
fontdictObject = self.embedTTF(filename)
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 508, in embedTTF
widths = [ get_char_width(charcode) for charcode in range(firstchar,
lastchar+1) ]
File
"/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 505, in get_char_width
unicode = cp1252.decoding_map[charcode] or 0
AttributeError: 'module' object has no attribute 'decoding_map'
The attached patch against lib/matplotlib/backends/backend_pdf.py
corrects this issue.
I am not currently a Debian user. This issue was reported by a
matplotlib user (Lorenzo Isella [EMAIL PROTECTED]) to the
[EMAIL PROTECTED] This issue should appear
whenever matplotlib-0.90.1 is run with Python-2.5, which appears to be
only on "lenny". "etch" has matplotlib-0.87 and Python-2.4, and "sid"
has matplotlib-0.91.2 (which incorporates the included patch upstream)
and Python-2.5.
Cheers,
Michael Droettboom
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
import matplotlib
matplotlib.use("pdf")
from pylab import *
plot([1,2,3])
savefig("test")
Index: backend_pdf.py
===================================================================
--- backend_pdf.py (revision 3418)
+++ backend_pdf.py (working copy)
@@ -500,11 +500,20 @@
# composite font, based on multi-byte characters.
from encodings import cp1252
- firstchar, lastchar = 0, 255
+ # The "decoding_map" was changed to a "decoding_table" as of Python
2.5.
+ if hasattr(cp1252, 'decoding_map'):
+ def decode_char(charcode):
+ return cp1252.decoding_map[charcode] or 0
+ else:
+ def decode_char(charcode):
+ return ord(cp1252.decoding_table[charcode]) or 0
+
def get_char_width(charcode):
- unicode = cp1252.decoding_map[charcode] or 0
+ unicode = decode_char(charcode)
width = font.load_char(unicode, flags=LOAD_NO_SCALE).horiAdvance
return cvt(width)
+
+ firstchar, lastchar = 0, 255
widths = [ get_char_width(charcode) for charcode in range(firstchar,
lastchar+1) ]
widthsObject = self.reserveObject('font widths')