mirror of https://github.com/scrapy/scrapy.git
Deprecate binary_is_text
This commit is contained in:
parent
9ee2ebea54
commit
f8cdd092d5
|
|
@ -9,7 +9,9 @@ import weakref
|
|||
from functools import partial, wraps
|
||||
from itertools import chain
|
||||
from typing import AsyncGenerator, AsyncIterable, Iterable, Union
|
||||
from warnings import warn
|
||||
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
from scrapy.utils.asyncgen import as_async_generator
|
||||
|
||||
|
||||
|
|
@ -165,6 +167,14 @@ def binary_is_text(data):
|
|||
""" Returns ``True`` if the given ``data`` argument (a ``bytes`` object)
|
||||
does not contain unprintable control characters.
|
||||
"""
|
||||
warn(
|
||||
(
|
||||
'scrapy.utils.python.binary_is_text is deprecated, use '
|
||||
'xtractmime.is_binary_data instead.'
|
||||
),
|
||||
ScrapyDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
if not isinstance(data, bytes):
|
||||
raise TypeError(f"data must be bytes, got '{type(data).__name__}'")
|
||||
return all(c not in _BINARYCHARS for c in data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue