[Cython] libcpp.string operators

Brent Pedersen bpederse at gmail.com
Wed Apr 20 18:40:07 CEST 2011


On Wed, Apr 20, 2011 at 10:34 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Brent Pedersen, 20.04.2011 18:29:
>>
>> On Wed, Apr 20, 2011 at 9:58 AM, Stefan Behnel wrote:
>>>
>>> Lisandro Dalcin, 20.04.2011 16:09:
>>>>>>
>>>>>> On Tue, Apr 19, 2011 at 2:45 PM, Brent Pedersen wrote:
>>>>>>>
>>>>>>> hi, i have been using a stub for the c++<string>    in a lot of my
>>>>>>> work.
>>>>>>> i decided to have a go at doing a proper string.pxd, pasted here:
>>>>>>>
>>>>>>> https://gist.github.com/929604
>>>>>>>
>>>> Looks pretty good. Could you fork the devel repo, add the pxd and the
>>>> test at appropriate places  and make a pull request? This is just in
>>>> order to give you credits for your work.
>>>
>>> Looks like this wasn't tested with Python 3, there are 16 failing tests
>>> more
>>> now.
>>>
>>>
>>> https://sage.math.washington.edu:8091/hudson/job/cython-devel-tests-py3k-cpp/952/
>>>
>> is the solution to prefix the string literals with 'b'? e.g.
>>
>>     >>>  test_indexing(b"asdf")
>>
>> or something else? that passes in python 2.6, 2.7 and 3.2 for me.
>
> ... but not in Py2.3-2.5. No, you need to either use byte strings created in
> Cython code, or use a hack that works on both Py2 and Py3, such as
> 'xyz'.encode('ASCII').
>
> Stefan
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>

good to know. thanks.


More information about the cython-devel mailing list