Skip to content

Commit

Permalink
Merge pull request #209 from pallets/formatter-super
Browse files Browse the repository at this point in the history
call string.Formatter.__init__
  • Loading branch information
davidism authored May 11, 2021
2 parents 88173cb + 15ffa63 commit 0bd14f0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/markupsafe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ def __html_format__(self, format_spec: str) -> "Markup":


class EscapeFormatter(string.Formatter):
__slots__ = ("escape",)

def __init__(self, escape: t.Callable[[t.Any], Markup]) -> None:
self.escape = escape
super().__init__()

def format_field(self, value: t.Any, format_spec: str) -> str:
if hasattr(value, "__html_format__"):
Expand Down Expand Up @@ -249,6 +252,8 @@ def _escape_argspec(
class _MarkupEscapeHelper:
"""Helper for :meth:`Markup.__mod__`."""

__slots__ = ("obj", "escape")

def __init__(self, obj: t.Any, escape: t.Callable[[t.Any], Markup]) -> None:
self.obj = obj
self.escape = escape
Expand Down

0 comments on commit 0bd14f0

Please sign in to comment.