Description
A number of expressions are getting turned into their string format when this should not occur.
Two examples are String[1] and the use of % to retrieve a prior Out expression..
How to Reproduce and Output Given
$ mathics3
Mathics3 10.0.1dev0
Running on linux CPython 3.13.12 (main, Feb 7 2026, 20:16:33) [GCC 13.3.0]
using SymPy 1.14.0, mpmath 1.3.0, numpy 2.4.2, cython 3.2.4, scipy 1.17.0, skimage 0.26.0
...
Quit by evaluating Quit[] or by pressing CONTROL-D.
In[1]:= 1+2
Out[1]= 3
In[2]:= %%
Out[2]= Out[0]
In[3]:= String[1]
Traceback (most recent call last):
File "mathics", line 7, in <module>
sys.exit(main())
~~~~^^
File "Mathics3/mathics-core/mathics/__main__.py", line 632, in main
interactive_eval_loop(shell, args.full_form, args.strict_wl_output)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Mathics3/mathics-core/mathics/__main__.py", line 372, in interactive_eval_loop
result = evaluation.evaluate(query, timeout=settings.TIMEOUT)
File "Mathics3/mathics-core/mathics/core/evaluation.py", line 277, in evaluate
result = evaluate()
File "Mathics3/mathics-core/mathics/core/evaluation.py", line 270, in evaluate
return self.format_output(self.last_eval, format)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "Mathics3/mathics-core/mathics/core/evaluation.py", line 406, in format_output
result = format_element(expr, self, SymbolOutputForm)
File "Mathics3/mathics-core/mathics/format/box/makeboxes.py", line 299, in format_element
result_box = apply_makeboxes_rules(formatted_expr, evaluation, form)
File "Mathics3/mathics-core/mathics/format/box/makeboxes.py", line 127, in apply_makeboxes_rules
return eval_generic_makeboxes(expr, form, evaluation)
File "Mathics3/mathics-core/mathics/format/box/makeboxes.py", line 227, in eval_generic_makeboxes
return printform_callback(elements[0], evaluation)
File "Mathics3/mathics-core/mathics/builtin/forms/print.py", line 260, in eval_makeboxes_outputform
text_outputform = str(render_output_form(expr, evaluation, **kwargs))
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Mathics3/mathics-core/mathics/format/form/outputform.py", line 267, in render_output_form
result = callback(format_expr, evaluation, **kwargs)
File "Mathics3/mathics-core/mathics/format/form/outputform.py", line 862, in string_render_output_form
return render_string(expr, **kwargs)
File "Mathics3/mathics-core/mathics/format/render/text.py", line 167, in string
if value.startswith('"') and value.endswith('"'): # nopep8
^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'
Expected behavior
For %% the value 3 should appear, not the string Out[1].
For String[1], the expression (not string) should come back
Additional context
This line looks wrong:
text_outputform = str(render_output_form(expr, evaluation, **kwargs))
There are probably other places where an unconditional str() is used instead of keeping the plain expr
Description
A number of expressions are getting turned into their string format when this should not occur.
Two examples are
String[1]and the use of%to retrieve a priorOutexpression..How to Reproduce and Output Given
Expected behavior
For
%%the value 3 should appear, not the stringOut[1].For
String[1], the expression (not string) should come backAdditional context
This line looks wrong:
There are probably other places where an unconditional
str()is used instead of keeping the plain expr