Skip to content

Commit

Permalink
[fix] another python3 string weird behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycojoker committed Mar 19, 2016
1 parent 17bb9a0 commit 25e5f27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions redbaron/base_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ def __repr__(self):

def __str__(self):
if runned_from_ipython():
return python_highlight(self.dumps())
return python_highlight(self.dumps()).decode("Utf-8")
else:
return self.dumps()

Expand Down Expand Up @@ -1444,10 +1444,9 @@ def __str__(self):
to_return = ""
for number, value in enumerate(self.data):
value = value[0]
to_return += ("%-3s " % number) + "\n ".join(value.__repr__().split("\n"))
to_return += (("%-3s " % number) + "\n ".join(value.__repr__().split("\n")))
to_return += "\n"
return to_return
return "%s" % [x.__repr__() for x in self.data]

def __getattr__(self, key):
return getattr(self.node_list, key)
Expand Down
4 changes: 2 additions & 2 deletions redbaron/syntax_highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def help_highlight(string):
return string

def python_highlight(string):
return string.encode("Utf-8")
return string

def python_html_highlight(string):
return string.encode("Utf-8")
return string
5 changes: 5 additions & 0 deletions tests/test_no_pygments.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def test_help(self):
def test_endl_html(self):
RedBaron("a\n").node_list[-1]._repr_html_()

def test_regression_repr(self):
red = RedBaron("a = 1 + caramba")
red[0].value.first.parent
str(red[0].value.first.parent)


class TestClassical(Test):
def setup_method(self, method):
Expand Down

0 comments on commit 25e5f27

Please sign in to comment.