diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-19 18:51:55 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-19 18:51:55 +0300 |
commit | 9691260ca94129d24114051f9b7e117cb2fa9ca8 (patch) | |
tree | 4be5f8dd15be6c352c08d90c188adbb1f48d0027 /contrib/python/MarkupSafe/py3/markupsafe | |
parent | 52a1ac58104ca032e718abb079dedc9600e85e34 (diff) | |
download | ydb-9691260ca94129d24114051f9b7e117cb2fa9ca8.tar.gz |
intermediate changes
ref:0bb75733c76b2fcaae048d43c4477755596029bb
Diffstat (limited to 'contrib/python/MarkupSafe/py3/markupsafe')
-rw-r--r-- | contrib/python/MarkupSafe/py3/markupsafe/__init__.py | 15 | ||||
-rw-r--r-- | contrib/python/MarkupSafe/py3/markupsafe/_native.py | 12 | ||||
-rw-r--r-- | contrib/python/MarkupSafe/py3/markupsafe/_speedups.c | 19 |
3 files changed, 9 insertions, 37 deletions
diff --git a/contrib/python/MarkupSafe/py3/markupsafe/__init__.py b/contrib/python/MarkupSafe/py3/markupsafe/__init__.py index d331ac3622..2acb04e47b 100644 --- a/contrib/python/MarkupSafe/py3/markupsafe/__init__.py +++ b/contrib/python/MarkupSafe/py3/markupsafe/__init__.py @@ -11,7 +11,7 @@ if t.TYPE_CHECKING: pass -__version__ = "2.0.1" +__version__ = "2.1.0" _striptags_re = re.compile(r"(<!--.*?-->|<[^>]*>)") @@ -92,19 +92,24 @@ class Markup(str): return NotImplemented - def __mul__(self, num: int) -> "Markup": + def __mul__(self, num: "te.SupportsIndex") -> "Markup": if isinstance(num, int): return self.__class__(super().__mul__(num)) - return NotImplemented # type: ignore + return NotImplemented __rmul__ = __mul__ def __mod__(self, arg: t.Any) -> "Markup": if isinstance(arg, tuple): + # a tuple of arguments, each wrapped arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg) - else: + elif hasattr(type(arg), "__getitem__") and not isinstance(arg, str): + # a mapping of arguments, wrapped arg = _MarkupEscapeHelper(arg, self.escape) + else: + # a single argument, wrapped with the helper and a tuple + arg = (_MarkupEscapeHelper(arg, self.escape),) return self.__class__(super().__mod__(arg)) @@ -280,9 +285,7 @@ try: from ._speedups import escape as escape from ._speedups import escape_silent as escape_silent from ._speedups import soft_str as soft_str - from ._speedups import soft_unicode except ImportError: from ._native import escape as escape from ._native import escape_silent as escape_silent # noqa: F401 from ._native import soft_str as soft_str # noqa: F401 - from ._native import soft_unicode # noqa: F401 diff --git a/contrib/python/MarkupSafe/py3/markupsafe/_native.py b/contrib/python/MarkupSafe/py3/markupsafe/_native.py index 6f7eb7a8cb..8117b2716d 100644 --- a/contrib/python/MarkupSafe/py3/markupsafe/_native.py +++ b/contrib/python/MarkupSafe/py3/markupsafe/_native.py @@ -61,15 +61,3 @@ def soft_str(s: t.Any) -> str: return str(s) return s - - -def soft_unicode(s: t.Any) -> str: - import warnings - - warnings.warn( - "'soft_unicode' has been renamed to 'soft_str'. The old name" - " will be removed in MarkupSafe 2.1.", - DeprecationWarning, - stacklevel=2, - ) - return soft_str(s) diff --git a/contrib/python/MarkupSafe/py3/markupsafe/_speedups.c b/contrib/python/MarkupSafe/py3/markupsafe/_speedups.c index 44967b1fdc..3c463fb82d 100644 --- a/contrib/python/MarkupSafe/py3/markupsafe/_speedups.c +++ b/contrib/python/MarkupSafe/py3/markupsafe/_speedups.c @@ -254,19 +254,6 @@ soft_str(PyObject *self, PyObject *s) } -static PyObject* -soft_unicode(PyObject *self, PyObject *s) -{ - PyErr_WarnEx( - PyExc_DeprecationWarning, - "'soft_unicode' has been renamed to 'soft_str'. The old name" - " will be removed in MarkupSafe 2.1.", - 2 - ); - return soft_str(self, s); -} - - static PyMethodDef module_methods[] = { { "escape", @@ -308,12 +295,6 @@ static PyMethodDef module_methods[] = { ">>> escape(soft_str(value))\n" "Markup('<User 1>')\n" }, - { - "soft_unicode", - (PyCFunction)soft_unicode, - METH_O, - "" - }, {NULL, NULL, 0, NULL} /* Sentinel */ }; |