Skip to content

Commit d85cd29

Browse files
committed
Fix incorrect coercion to string method
D/encoding worked differently and more loosely in py2. Now decoding converts bytes to unicode, vice versa for encoding. Also, fix a duplicate conditional expression that captures strings to capture integers too.
1 parent b386116 commit d85cd29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

opentreemap/exporter/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
def sanitize_unicode_value(value):
55
# make sure every text value is of type 'str', coercing unicode
66
if isinstance(value, str):
7-
return value.encode("utf-8")
8-
elif isinstance(value, str):
97
return value
8+
elif isinstance(value, int):
9+
return str(value)
1010
else:
11-
return str(value).encode("utf-8")
11+
return value.decode("utf-8")
1212

1313

1414
# originally copied from, but now divergent from:

0 commit comments

Comments
 (0)