[Python-Dev] unicode vs buffer (array) design issue can crash interpreter

Neal Norwitz nnorwitz at gmail.com
Thu Mar 30 08:56:18 CEST 2006

See http://python.org/sf/1454485 for the gory details.  Basically if
you create a unicode array (array.array('u')) and try to append an
8-bit string (ie, not unicode), you can crash the interpreter.

The problem is that the string is converted without question to a
unicode buffer.  Within unicode, it assumes the data to be valid, but
this isn't necessarily the case.  We wind up accessing an array with a
negative index and boom.

This is perhaps somewhat simplified and not exactly accurate. 
Probably best to look over the patch and make comments there on how
best to fix this issue.


More information about the Python-Dev mailing list