Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Some text function messages cleanup, deprecate to_native_str.

Andrey Rakhmatullin5b70b051a6ce
diff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.py
index b0a526b72..a81404afb 100644
--- a/scrapy/http/response/__init__.py
+++ b/scrapy/http/response/__init__.py
@@ -88,7 +88,7 @@ class Response(object_ref):
@property
def text(self):
"""For subclasses of TextResponse, this will return the body
- as text (unicode object in Python 2 and str in Python 3)
+ as str
"""
raise AttributeError("Response content isn't text")
diff --git a/scrapy/utils/python.py b/scrapy/utils/python.py
index 5009aab81..974abaeb1 100644
--- a/scrapy/utils/python.py
+++ b/scrapy/utils/python.py
@@ -90,7 +90,7 @@ def to_unicode(text, encoding=None, errors='strict'):
if isinstance(text, six.text_type):
return text
if not isinstance(text, (bytes, six.text_type)):
- raise TypeError('to_unicode must receive a bytes, str or unicode '
+ raise TypeError('to_unicode must receive a bytes or str '
'object, got %s' % type(text).__name__)
if encoding is None:
encoding = 'utf-8'
@@ -103,16 +103,16 @@ def to_bytes(text, encoding=None, errors='strict'):
if isinstance(text, bytes):
return text
if not isinstance(text, six.string_types):
- raise TypeError('to_bytes must receive a unicode, str or bytes '
+ raise TypeError('to_bytes must receive a str or bytes '
'object, got %s' % type(text).__name__)
if encoding is None:
encoding = 'utf-8'
return text.encode(encoding, errors)
+@deprecated('to_unicode')
def to_native_str(text, encoding=None, errors='strict'):
- """ Return str representation of ``text``
- (bytes in Python 2.x and unicode in Python 3.x). """
+ """ Return str representation of ``text``. """
return to_unicode(text, encoding, errors)