From 2d1e8f38e973f88aeb29dc51caa0f57ab86efc67 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sat, 8 Feb 2020 21:00:22 +0000 Subject: BUG, MAINT: Stop using the error-prone deprecated Py_UNICODE apis These APIs work with either UCS2 or UCS4, depending on the value of `Py_UNICODE_WIDE`. After python 3.3, there's a better way to handle this type of thing, which means we no longer have to care about this. Fixes gh-3258 Fixes gh-15363 --- numpy/core/defchararray.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'numpy/core/defchararray.py') diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 942a698a9..b22d6b85e 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -2679,25 +2679,6 @@ def array(obj, itemsize=None, copy=True, unicode=None, order=None): itemsize = len(obj) shape = len(obj) // itemsize - if unicode: - if sys.maxunicode == 0xffff: - # On a narrow Python build, the buffer for Unicode - # strings is UCS2, which doesn't match the buffer for - # NumPy Unicode types, which is ALWAYS UCS4. - # Therefore, we need to convert the buffer. On Python - # 2.6 and later, we can use the utf_32 codec. Earlier - # versions don't have that codec, so we convert to a - # numerical array that matches the input buffer, and - # then use NumPy to convert it to UCS4. All of this - # should happen in native endianness. - obj = obj.encode('utf_32') - else: - obj = str(obj) - else: - # Let the default Unicode -> string encoding (if any) take - # precedence. - obj = bytes(obj) - return chararray(shape, itemsize=itemsize, unicode=unicode, buffer=obj, order=order) -- cgit v1.2.1