[Python-Dev] Python 2.2 chr representation errors with embedded C (original) (raw)

Mark Szigety mszigety@cisco.com
Fri, 29 Mar 2002 09:12:08 -0500


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 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!

Thanks, Mark