diff --git a/mathics/core/pattern.py b/mathics/core/pattern.py index b0a398d58..334098090 100644 --- a/mathics/core/pattern.py +++ b/mathics/core/pattern.py @@ -83,6 +83,8 @@ def create(expr: BaseElement) -> "Pattern": Otherwise, if ``expr`` is an ``Atom``, create and return ``AtomPattern`` for ``expr``. Otherwise, create and return and ``ExpressionPattern`` for ``expr``. """ + if not isinstance(expr, (Atom, Expression)): + expr = expr.to_expression() name = expr.get_head_name() pattern_object = pattern_objects.get(name)