Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.

Home Page:https://mathics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raising a` BoxExpressionError` is not handled properly?

rocky opened this issue · comments

Description

A BoxExpressionError does not seem to be handled properly.

How to Reproduce

Evaluate in Django or mathicsscript

Graphics3D[Cylinder[0]]

Output Given

Traceback (most recent call last):
...
  File "Mathics3/mathics-core/mathics/builtin/box/expression.py", line 51, in __new__
    instance = super().__new__(cls, *elements, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Mathics3/mathics-core/mathics/core/builtin.py", line 465, in __new__
    instance.init(*args, **kwargs)
  File 'Mathics3/mathics-core/mathics/builtin/box/graphics3d.py", line 602, in init
    raise BoxExpressionError
mathics.core.exceptions.BoxExpressionError

Expected behavior

Actually, I do not know what is expected. I know that an uncaught exception is not expected. In mathicsscript or mathics, this terminates the session.

Your Environment

All environments.

Additional context

Noticed in testing out things for a possible new release.

I can make a stab at addressing, but I am at a loss for what the right behavior is.

For Graphics3D[Sphere[1, 0, 1]] I have turned this into a Syntax error giving:

mathics.core.exceptions.BoxExpressionError: In Sphere[], expecting 2 elements: point(s) and radius, got 3.

but I don't know if this is right.

Ideally, the failing box expression should be replaced by a red rectangle in the picture, and showing an error message:
imagen

This can be done by catching the exception in line 233 of mathics/builtin/box/graphics3d.py

This issue handled, although the specific case Graphics3D[Cylinder[0]] is not. #970 is the follow on.