One function

Markup in pallets/markupsafe

The author described this change as raise error on missing single placeholder. It counts as a record because the check below fails on the code as it stood at 37c44e554 and passes on 3d809aed7, with nothing else changed between the two runs.

Fix saved2021-08-05
Sharing licenceBSD-3-Clause · LICENSE.txt
Change size+6 1

What the code was meant to do, written into the code itself as a docstring

A string that is ready to be safely inserted into an HTML or XML document, either because it was escaped or because it was marked safe. Passing an object to the constructor converts it to text and wraps it to mark it safe without escaping. To escape the text, use the :meth:`escape` class method instead. This implements the `__html__()` interface that some frameworks use. Passing an object that implements `__html__()` will wrap the output of that method, marking it safe. This is a subclass of :class:`str`. It has the same methods, but escapes their arguments and returns a `Markup` instance.

The change

7272
7373 def __mod__(self, arg: t.Any) -> "Markup":
7474 if isinstance(arg, tuple):
75+ # a tuple of arguments, each wrapped
7576 arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg)
76- else:
77+ elif hasattr(type(arg), "__getitem__") and not isinstance(arg, str):
78+ # a mapping of arguments, wrapped
7779 arg = _MarkupEscapeHelper(arg, self.escape)
80+ else:
81+ # a single argument, wrapped with the helper and a tuple
82+ arg = (_MarkupEscapeHelper(arg, self.escape),)
7883
7984 return self.__class__(super().__mod__(arg))
8085

The check that tells the two apart

failpass·tests/test_markupsafe.py::test_missing_interpol[foo]

Check file tests/test_markupsafe.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it37c44e554b1b05f8cec09424ad6057b79a0d88b0
Broken version dated2021-08-03
Modulemarkupsafe.__init__
Units changedMarkup
Fingerprintd7669ca73a610c01
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.