Skip to content

Commit 651032b

Browse files
jenshnielsenstory645
authored andcommitted
dtype names must be strings and not unicode in python2
1 parent 5e21f24 commit 651032b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/mlab.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,8 +2385,10 @@ def rec_append_fields(rec, names, arrs, dtypes=None):
23852385
dtypes = dtypes * len(arrs)
23862386
else:
23872387
raise ValueError("dtypes must be None, a single dtype or a list")
2388-
2389-
newdtype = np.dtype(rec.dtype.descr + list(zip(names, dtypes)))
2388+
old_dtypes = rec.dtype.descr
2389+
if six.PY2:
2390+
old_dtypes = [(a[0].encode('utf-8'), a[1]) for a in old_dtypes]
2391+
newdtype = np.dtype(old_dtypes + list(zip(names, dtypes)))
23902392
newrec = np.recarray(rec.shape, dtype=newdtype)
23912393
for field in rec.dtype.fields:
23922394
newrec[field] = rec[field]

0 commit comments

Comments
 (0)