[reportlab-users] Puzzling Error - Solved!
Tue, 5 Nov 2002 11:20:44 -0700
This was exactly the solution! Thanks Andy...
> 'unicode' object has no attribute 'write'
> <traceback object at 0x0328A4D0>
My guess is you are passing a unicode string as a filename
and not an 8-bit python string. Currently we cannot easily test
for unicode as we have to run on pre-Unicode versions of
The relevant code is in pdfdoc, class PDFDocument, method saveToFile
and does this!
if type(filename) is StringType:
myfile =3D 1
f =3D open(filename, "wb")
myfile =3D 0
f =3D filename # IT BETTER BE A FILE-LIKE OBJECT!
So if you pass a Unicode string it assumes it's something
Solution: either do=20
filename =3D str(filename)
in your code before setting up the canvas, or explicitly pass
in an open file object.