mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-25 13:41:13 +08:00
Remove utf8_repr from _compatibility.py
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user