Skip to content

Commit 758e07f

Browse files
Merge pull request #472 from matthew-brett/py33-byte-string-recursion
MRG: fix recursion error on Python 3.3 Python 3.3 gives errors for byte strings as inputs to `format`; convert byte strings to unicode strings before `format` method.
2 parents 25c98ff + f992edf commit 758e07f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nibabel/streamlines/trk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ def __str__(self):
729729
vars['property_names'] = "\n ".join([asstr(s)
730730
for s in vars['property_name']
731731
if len(s) > 0])
732+
# Make all byte strings into strings
733+
# Fixes recursion error on Python 3.3
734+
vars = dict((k, asstr(v) if hasattr(v, 'decode') else v)
735+
for k, v in vars.items())
732736
return """\
733737
MAGIC NUMBER: {MAGIC_NUMBER}
734738
v.{version}

0 commit comments

Comments
 (0)