[reportlab-users] Possible String/Unicode bug in reportlab. Where do I report it?
Henning von Bargen
henning.vonbargen at arcor.de
Wed Jun 24 16:24:25 EDT 2009
> From: Roberto Alsina <ralsina at netmanagers.com.ar>
> Subject: Re: [reportlab-users] Possible String/Unicode bug in
> reportlab. Where do I report it?
> To: Support list for users of Reportlab software
> <reportlab-users at reportlab.com>
> Message-ID: <200906202001.39444.ralsina at netmanagers.com.ar>
> Content-Type: Text/Plain; charset="utf-8"
>
> On Saturday 20 June 2009 19:47:40 Chris Bergstresser wrote:
>> Hi all --
>>
>> I just started using ReportLab (through the rst2pdf library) and so
>> I'm not entirely sure this isn't a problem with rst2pdf, but it
>> certainly looks like a ReportLab bug. When it tries to draw tables, I
>> get a:
>>
>> ValueError: Unknown color u'black'
>>
>> The last line of the stack is:
>>
>> File
>> "c:\Python26\Lib\site-packages\reportlab-2.3-py2.6-win32.egg\reportlab\pdfg
>> en\textobject.py", line 98, in setStrokeColor
>> raise ValueError('Unknown color %r' % aColor)
>>
>> ... and a brief check of the code reveals this check above it:
>>
>> elif type(aColor) is StringType:
>> self.setStrokeColor(toColor(aColor))
>>
>> obviously, this fails because aColor is Unicode. (For that matter,
>> toColor only accepts binary strings as well). I cannot, for the life
>> of me, fathom *why*. At any rate, the fix is trivial, depending on
>> the desired behavior--since I don't understand the rationale for
>> refusing to accept Unicode in the first place, I'm hesitant to suggest
>> a specific fix.
>
> Since I intend to keep supporting RL 2.3, could you post a simple test case in
> rst2pdf's bug tracker? Maybe it *is* rst2pdf's fault, and if it isn't I need
> to create a workaround anyway :-)
>
There has been a change in the RL trunk colors.py recently, adding
support for unicode colors, but that doesn't fix the error.
The following additional little patch for reportlab/pdfgen/textobject.py
makes rst2pdf-0.11 work with the RL trunk:
Index: textobject.py
===================================================================
--- textobject.py (revision 3505)
+++ textobject.py (working copy)
@@ -92,7 +92,7 @@
self.setStrokeColorCMYK(aColor[0], aColor[1],
aColor[2], aColor[3])
else:
raise ValueError('Unknown color %r' % aColor)
- elif type(aColor) is StringType:
+ elif isinstance(aColor, basestring):
self.setStrokeColor(toColor(aColor))
else:
raise ValueError('Unknown color %r' % aColor)
Henning
More information about the reportlab-users
mailing list