8000 Fix encoding bugs in Python2 (non-ASCII characters) (#80) · tableau/document-api-python@a4e41f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4e41f9

Browse files
MiguelSRt8y8
authored andcommitted
< 10000 /div>
Fix encoding bugs in Python2 (non-ASCII characters) (#80)
1 parent 2a47af3 commit a4e41f9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tableaudocumentapi/datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
def _get_metadata_xml_for_field(root_xml, field_name):
3232
if "'" in field_name:
3333
field_name = sax.escape(field_name, {"'": "&apos;"})
34-
xpath = ".//metadata-record[@class='column'][local-name='{}']".format(field_name)
34+
xpath = u".//metadata-record[@class='column'][local-name='{}']".format(field_name)
3535
return root_xml.find(xpath)
3636

3737

tableaudocumentapi/field.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,9 @@ def _read_description(xmldata):
199199
if description is None:
200200
return None
201201

202-
return u'{}'.format(ET.tostring(description, encoding='utf-8')) # This is necessary for py3 support
202+
description_string = ET.tostring(description, encoding='utf-8')
203+
# Format expects a unicode string so in Python 2 we have to do the explicit conversion
204+
if isinstance(description_string, bytes):
205+
description_string = description_string.decode('utf-8')
206+
207+
return description_string

0 commit comments

Comments
 (0)
0