Skip to content

Commit 21edeea

Browse files
committed
handle create pattern when expr is not an Expression/Atom
1 parent c8cbe50 commit 21edeea

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mathics/core/pattern.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def create(expr: BaseElement) -> "Pattern":
8383
Otherwise, if ``expr`` is an ``Atom``, create and return ``AtomPattern`` for ``expr``.
8484
Otherwise, create and return and ``ExpressionPattern`` for ``expr``.
8585
"""
86+
if not isinstance(expr, (Atom, Expression)):
87+
expr = expr.to_expression()
8688

8789
name = expr.get_head_name()
8890
pattern_object = pattern_objects.get(name)

0 commit comments

Comments
 (0)