From f8cdd092d5ac8a3a0e987713cc05c6aa86087369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Tue, 10 Jan 2023 21:32:00 +0100 Subject: [PATCH] Deprecate binary_is_text --- scrapy/utils/python.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scrapy/utils/python.py b/scrapy/utils/python.py index 9df1c91de..983e3e322 100644 --- a/scrapy/utils/python.py +++ b/scrapy/utils/python.py @@ -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)