[reportlab-users] Re: FutureWarnings in ttfonts.py with Python 2.3
Fri, 2 Apr 2004 23:16:13 +0100
In message <2546C8F5D3D2D411857F00508BDCA4E8033B30B7@dalbar_mail.dalbar.
com>, Marc Stober <MStober@DALBAR.com> writes
>> .... I don't get that with the latest pyd's and the CVS code. It's an
>> utter pain that they did the unification without introducing
>> an unsigned
>> 32 bit int so the bit twiddling can continue. The fix seems
>> to be to use
>> def _L2U32(L):
>> return unpack('l',pack('L',L))
>> _L2U32((hi << 16L) | (lo & 0xFFFF))
>I worked out a solution. The function above helps, but it's a little more
>complicated. The future warning is still raised when the hi << 16L is
>evaluated, before being passed to the function.
>I think that I now understand this warning is trying to say, "warning,
>bit-shifting is an ugly hack for modulo multiplication." So, I was able to
>use modulo multiplication directly, such as:
>_L2U32((hi * (2**16) % (2**32)) ... etc.
>The _L2U32 function is still needed to convert the result back to regular
>I've uploaded a revised version of ttfonts.py to the SourceForge Patches
>area and tested it under Python 2.2 and 2.3. (A simple test it to generate
>the ReportLab userguide.)
>Also, I don't think you'd get these warnings if you have the _rl_accel dll
>installed, as the bit-shifting part will be executed in the dll.
>Hope this helps!
thanks for the effort, I'll take a look at the patch tomorrow.