Skip to content

Commit cfb1ded

Browse files
committed
Restore SplashJsonResponse.body_as_unicode() with a deprecation warning
1 parent 8e8c6d8 commit cfb1ded

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Changes
77
* Removed official support for Python 2.7, 3.4, 3.5 and 3.6, and added official
88
support for Python 3.9, 3.10 and 3.11.
99

10-
* Removed ``SplashJsonResponse.body_as_unicode()``, replaced by
10+
* Deprecated ``SplashJsonResponse.body_as_unicode()``, to be replaced by
1111
``SplashJsonResponse.text``.
1212

1313
* Removed calls to obsolete ``to_native_str``, removed in Scrapy 2.8.

scrapy_splash/response.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import base64
66
import re
7+
from warnings import warn
78

89
from scrapy.http import Response, TextResponse
910
from scrapy import Selector
@@ -128,6 +129,17 @@ def data(self):
128129
def text(self):
129130
return self._ubody
130131

132+
def body_as_unicode(self):
133+
warn(
134+
(
135+
"The body_as_unicode() method is deprecated, use the text "
136+
"property instead."
137+
),
138+
DeprecationWarning,
139+
stacklevel=2,
140+
)
141+
return self._ubody
142+
131143
@property
132144
def _ubody(self):
133145
if self._cached_ubody is None:

0 commit comments

Comments
 (0)