[reportlab-users] Puzzling Error

Jerome Alet reportlab-users@reportlab.com
Wed, 6 Nov 2002 10:30:26 +0100


On Wed, Nov 06, 2002 at 08:56:57AM +0000, Robin Becker wrote:

> done, but as I explained this indicates some seriously strange
> programming is going on. I tried to debug this to find out why the
> __str__ etc wasn't happening and failed. So far as I'm aware the
> intention of __str__ didn't change between 1.5.2 and 2.2. Something else
> eg the method resolution order did, but I think not between 1.5.2 and
> 2.1 so I find it strange that these break in different ways for the 3
> pythons.

I'm not sure it's that.

I think it's probably the way how class instances are used as hash keys
which has changed.

> Having a magic instance in place of a string object and relying on magic
> to get it to work every where is bound to break sometime. I understand
> the proxy concept, but I think maintenance will be a problem. The danger
> will come when people start using unicode etc when the str calls won't
> always be the right thing to do.

the place of unicode is more on the end-user/application interaction 
side, if I understand correctly, but here we talk about font names 
which should be used only by the developper who can ensure they are 
not stored in unicode strings. 

that was the less intrusive way I thought of to make it work with 
all Python versions, but another solution is to put a Python version 
check in pycanvas.py and fail if not >= 2.2. This way we could 
delete these two "magic" lines of code from pdfmetric's getTypeFace 
and registerFont, as well as the __coerce__ and __str__ methods from 
pycanvas's PDFAction class, since the original pycanvas code works 
fine in 2.2 (AFAICT). 

It's not like if pycanvas was an indispensable submodule, IMHO 
limiting its access to 2.2 and superior is OK, unless of course you 
explicitely want it to work with older versions of Python. 

bye,

Jerome Alet