cython / cython

The most widely used Python to C compiler
https://cython.org
Apache License 2.0
9.51k stars 1.49k forks source link

typed memoryviews don't support unicode type #3364

Open brmmm3 opened 4 years ago

brmmm3 commented 4 years ago

I'm using Cython 0.29.15 with Python 2.7.16. When I create an array for Unicode characters in Python it works as expected:

arr = array,array('u' [u'a'])

But when I try to get a typed memory view on this or when I try to create the same with Cython code I get:

ValueError: Does not understand character buffer dtype format string ('u')

Code is:

cdef array.array[Py_UNICODE] arr_view = arr

McSinyx commented 4 years ago

Similar to #3367, does the problem persist on Python 3? AFAIK Python 2 is deprecated as of the beginning of this year.

mattip commented 4 years ago

@McSinyx Python 2 is not "deprecated", it is "sunsetted" which mean it is no longer supported by the CPython/PSF team. That is a subtle difference, but meaningful to libraries like Cython. FWIW, I could not find a statement like "Cython is deprecating support for Python 2 as of version X" on the documentation web site, please correct me if I am wrong.

da-woods commented 4 years ago

I believe Cython is planning on dropping support for Python 2 in version 3.1. See https://github.com/cython/cython/issues/2800. For the moment that's in the future (but not the distant future), so Python 2-only bugs are still bugs.

It doesn't look like this works on Python3 either.