diff --git a/parso/_compatibility.py b/parso/_compatibility.py index f1f0b0f..0f1c85b 100644 --- a/parso/_compatibility.py +++ b/parso/_compatibility.py @@ -44,24 +44,6 @@ def u(string): return string -def utf8_repr(func): - """ - ``__repr__`` methods in Python 2 don't allow unicode objects to be - returned. Therefore cast them to utf-8 bytes in this decorator. - """ - def wrapper(self): - result = func(self) - if isinstance(result, unicode): - return result.encode('utf-8') - else: - return result - - if sys.version_info.major >= 3: - return func - else: - return wrapper - - if sys.version_info < (3, 5): """ A super-minimal shim around listdir that behave like diff --git a/parso/python/tree.py b/parso/python/tree.py index 42fb9be..00b3a12 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -48,7 +48,7 @@ try: except ImportError: from collections import Mapping -from parso._compatibility import utf8_repr, unicode +from parso._compatibility import unicode from parso.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf, \ search_ancestor from parso.python.prefix import split_prefix @@ -175,7 +175,6 @@ class EndMarker(_LeafWithoutNewlines): __slots__ = () type = 'endmarker' - @utf8_repr def __repr__(self): return "<%s: prefix=%s end_pos=%s>" % ( type(self).__name__, repr(self.prefix), self.end_pos @@ -187,7 +186,6 @@ class Newline(PythonLeaf): __slots__ = () type = 'newline' - @utf8_repr def __repr__(self): return "<%s: %s>" % (type(self).__name__, repr(self.value)) diff --git a/parso/tree.py b/parso/tree.py index b115197..c1bf759 100644 --- a/parso/tree.py +++ b/parso/tree.py @@ -1,7 +1,7 @@ import sys from abc import abstractmethod, abstractproperty -from parso._compatibility import utf8_repr, encoding +from parso._compatibility import encoding from parso.utils import split_lines @@ -238,7 +238,6 @@ class Leaf(NodeOrLeaf): end_pos_column = len(lines[-1]) return end_pos_line, end_pos_column - @utf8_repr def __repr__(self): value = self.value if not value: @@ -333,7 +332,6 @@ class BaseNode(NodeOrLeaf): def get_last_leaf(self): return self.children[-1].get_last_leaf() - @utf8_repr def __repr__(self): code = self.get_code().replace('\n', ' ').replace('\r', ' ').strip() if not sys.version_info.major >= 3: