Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: I added method .decode(utf-8) after calling C-func of getting… #203

Merged
merged 4 commits into from Aug 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions pygraphviz/agraph.py
Expand Up @@ -180,7 +180,7 @@ def __init__(self, thing=None,
# get the encoding from the "charset" graph attribute
item = gv.agget(self.handle, b'charset')
if item is not None:
self.encoding = item
self.encoding = item if type(item) is not bytes else item.decode('utf-8')
else:
self.encoding = _DEFAULT_ENCODING
else:
Expand Down Expand Up @@ -1742,8 +1742,8 @@ def __init__(self, handle, atype):
ghandle = gv.agraphof(handle)
root_handle = gv.agroot(ghandle) # get root graph
try:
ah = gv.agattr(root_handle, 0, b'charset', None)
self.encoding = gv.agattrdefval(ah)
item = gv.agattrdefval(gv.agattr(root_handle, 0, b'charset', None))
self.encoding = item if type(item) is not bytes else item.decode('utf-8')
except KeyError:
self.encoding = _DEFAULT_ENCODING

Expand Down Expand Up @@ -1834,8 +1834,8 @@ def __init__(self, handle, atype):
# get the encoding
root_handle = gv.agroot(self.ghandle) # get root graph
try:
ah = gv.agattr(root_handle, 0, b'charset', None)
self.encoding = gv.agattrdefval(ah)
item = gv.agattrdefval(gv.agattr(root_handle, 0, b'charset', None))
self.encoding = item if type(item) is not bytes else item.decode('utf-8')
except KeyError:
self.encoding = _DEFAULT_ENCODING

Expand Down