Skip to content

Commit 54bb00b

Browse files
authored
fix exact str check (#469)
2 parents b529164 + 7add29c commit 54bb00b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Version 3.0.1
44
Unreleased
55

66
- Address compiler warnings that became errors in GCC 14. :issue:`466`
7+
- Fix compatibility with proxy objects. :issue:`467`
78

89

910
Version 3.0.0

src/markupsafe/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def escape(s: t.Any, /) -> Markup:
3434
"""
3535
# If the object is already a plain string, skip __html__ check and string
3636
# conversion. This is the most common use case.
37-
if s.__class__ is str:
37+
# Use type(s) instead of s.__class__ because a proxy object may be reporting
38+
# the __class__ of the proxied value.
39+
if type(s) is str:
3840
return Markup(_escape_inner(s))
3941

4042
if hasattr(s, "__html__"):

0 commit comments

Comments
 (0)