[C++-sig] supporting binary strings
David Abrahams
dave at boost-consulting.com
Wed Oct 16 21:54:48 CEST 2002
greg Landrum <greglandrum at mindspring.com> writes:
> The default string conversion behavior of BPLv2 truncates strings
> containing nulls. BPLv1 did not do this (Python strings containing
> nulls were properly passed to the C++ layer).
>
> I've made two small mods to change the behavior back. A context diff
> for the changes is attached.
Your changes look reasonable to me. The ones in the .cpp file are not
the most efficient implementation possible, because two copies of the
C++ string will be created. A more-efficient implementation would not
be able to use the slot_rvalue_from_python scaffolding, though. I
think I'll apply your patch; we can optimize later if neccessary.
> I'm not super comfortable with the new type conversion system yet, so
> I'm not 100% sure that my change from char* to string in the PyString
> converter isn't going to break things in other peoples' code (though
> all the tests pass for me).
It certainly could, if they're somehow depending on the
zero-terminating behavior. However, I think that would just be wrong,
so you win this round ;-)
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Building C/C++ Extensions for Python: Dec 9-11, Austin, TX
http://www.enthought.com/training/building_extensions.html
More information about the Cplusplus-sig
mailing list