Python 2.2 chr representation errors with embedded C

Bengt Richter bokr at oz.net
Fri Mar 29 14:19:15 EST 2002


On Fri, 29 Mar 2002 09:12:08 -0500, "Mark Szigety" <mszigety at cisco.com> wrote:

>Hello,
>
>I have recently made the upgrade to Python 2.2 from 1.5.2.  In the
>Python application which I develop, we have several embedded C
>functions, one of which is a simple function to convert a hex string to
>octal--it simply chars each byte and returns the new buffer.  However, I
What do you mean "hex string" and "to octal" ? is this a string->string
conversion, changing a hex string representation of an integer to
an octal string representation of the same integer, or what? Please define your terms.

Since it's so simple, why not post the actual code you're having trouble with??

>have noticed a 0.01% error rate in Python 2.2 which I did not see in
>Python 1.5.2 (it was 100% accurate).  That is, 1 out of 10,000 hex
>strings will be converted incorrectly in the C function, usually one
>byte is returned as \x00 instead of what is should be.  I also have
>noticed that in Python 2.2, chr(0xff) returns \xff instead of \377 in
>Python 1.5.2.  Could this be the source of the communication breakdown?
>
>I should mention that writing a similar conversion function totally in
>Python is 100% accurate in Python 2.2 as well as Python 1.5.2, although
>it is an order of magnitude slower.
>
>Any information about the apparent source of this issue would be
>appreciated!

I dislike playing 20-questions games when being asked to help.
I guess I should have eaten a better breakfast ;-/



Regards,
Bengt Richter



More information about the Python-list mailing list