Skip to content

Commit

Permalink
BUG: fix string splitting for Py2
Browse files Browse the repository at this point in the history
  • Loading branch information
kohr-h committed Jun 19, 2018
1 parent 0880e63 commit 1c8a692
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions odl/util/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,9 @@ def attribute_repr_string(inst_str, attr_str):
# no parentheses -> keep instance string as-is and append attr string
parts = [inst_str, attr_str]
else:
leftsplit = inst_str.split('(', maxsplit=1)
left, rest = leftsplit
right, middle = rest[::-1].split(')', maxsplit=1)
# TODO(kohr-h): use `maxsplit=1` kwarg, not supported in Py 2
left, rest = inst_str.split('(', 1)
right, middle = rest[::-1].split(')', 1)
middle, right = middle[::-1], right[::-1]

if middle.startswith('\n') and middle.endswith('\n'):
Expand Down Expand Up @@ -1391,8 +1391,9 @@ class that is created through a method, for instance ::
# Length of the line to the end of the method name
meth_line_start_len = len(inst_str) + 1 + len(meth_str)
else:
left, rest = inst_str.split('(', maxsplit=1)
right, middle = rest[::-1].split(')', maxsplit=1)
# TODO(kohr-h): use `maxsplit=1` kwarg, not supported in Py 2
left, rest = inst_str.split('(', 1)
right, middle = rest[::-1].split(')', 1)
middle, right = middle[::-1], right[::-1]
if middle.startswith('\n') and middle.endswith('\n'):
# Already on multiple lines
Expand Down

0 comments on commit 1c8a692

Please sign in to comment.