Skip to content

escape function does not return Markup class for instances implementing __html__ method #68

@mila

Description

@mila

The escape function does not wrap a return value of __html__ method as Markup.

Expected behaviour documented in README.rst:

>>> class Foo(object):
...  def __html__(self):
...   return '<strong>Nice</strong>'
...
>>> escape(Foo())
Markup(u'<strong>Nice</strong>')

Actual behaviour:

>>> from markupsafe import escape
>>> class Foo(object):
...  def __html__(self):
...   return '<strong>Nice</strong>'
...
>>> escape(Foo())
'<strong>Nice</strong>'

I am using the 1.0 version I get same result for both native and speedups implementations.

>>> import markupsafe
>>> markupsafe.__version__
'1.0'
>>> from markupsafe._speedups import escape
>>> escape(Foo())
'<strong>Nice</strong>'
>>> from markupsafe._native import escape
>>> escape(Foo())
'<strong>Nice</strong>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions