summaryrefslogtreecommitdiff
path: root/numpy/core/defchararray.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2020-02-08 21:00:22 +0000
committerEric Wieser <wieser.eric@gmail.com>2020-02-08 21:00:22 +0000
commit2d1e8f38e973f88aeb29dc51caa0f57ab86efc67 (patch)
tree94eed4a75dbab0e73a11ea5935cdabc643d9cceb /numpy/core/defchararray.py
parent9531e5e1ba37b95f4d3b7f355c2869cab2e139d5 (diff)
downloadnumpy-2d1e8f38e973f88aeb29dc51caa0f57ab86efc67.tar.gz
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
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r--numpy/core/defchararray.py19
1 files changed, 0 insertions, 19 deletions
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)