Skip to content

Commit 4bde09c

Browse files
committed
Explicitly decode to UTF-8
Python 3 defaults to UTF-8 decoding, but Python 2 does not. Also, str.decode() on Python 2.6 doesn't accept keyword arguments.
1 parent c071bc6 commit 4bde09c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

openslide/deepzoom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,4 @@ def get_dzi(self, format):
230230
tree = ElementTree(element=image)
231231
buf = BytesIO()
232232
tree.write(buf, encoding='UTF-8')
233-
return buf.getvalue().decode()
233+
return buf.getvalue().decode('UTF-8')

openslide/lowlevel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _check_close(_result, _func, args):
128128
# Convert returned byte array, if present, into a string
129129
def _check_string(result, func, _args):
130130
if func.restype is c_char_p and result is not None:
131-
return result.decode(errors='replace')
131+
return result.decode('UTF-8', 'replace')
132132
else:
133133
return result
134134

@@ -147,7 +147,7 @@ def _check_name_list(result, func, args):
147147
name = result[i]
148148
if not name:
149149
break
150-
names.append(name.decode(errors='replace'))
150+
names.append(name.decode('UTF-8', 'replace'))
151151
return names
152152

153153
# resolve and return an OpenSlide function with the specified properties

0 commit comments

Comments
 (0)