mathics / Mathics

This repository is for archival. Please see https://github.com/Mathics3/mathics-core
https://mathics.org
Other
2.08k stars 208 forks source link

Django Interface Exception on every input #1499

Closed egrath closed 2 years ago

egrath commented 2 years ago

In Mathics 3.1.0, running on Python 3.9.5 on Windows, every input in the Django Webinterface results in the following error:

System::exception:
Exception raised: 'NoneType' object has no attribute 'replace' 

The issue occurs even on a complete fresh Python installation with just Mathics installed by:

pip install mathics3-omnibus

This issue only occurs on the Webinterface, running a interactive console session works as expected.

rocky commented 2 years ago

What's the full Python traceback? Also copy the information from the "about" page, generally it is http://127.0.0.1:8000/about

There will be a release of everything Mathics core and Mathics Django in about a week or so. A lot has changed and some changes are incompatible. So it doesn't surprise me that things are broken in Django.

A workaround is to use the docker container for Mathics Django.

egrath commented 2 years ago

Sorry for the delay, the full traceback is:

System::exception:
Exception raised: 'NoneType' object has no attribute 'replace' Traceback (most recent call last):
File "c:\temp\mathics\lib\site-packages\mathics_django\web\views.py", line 265, in query result = evaluation.evaluate(expr, timeout=settings.TIMEOUT)
File "c:\temp\mathics\lib\site-packages\mathics\core\evaluation.py", line 361, in evaluate result = run_with_timeout_and_stack(evaluate, timeout, self)
File "c:\temp\mathics\lib\site-packages\mathics\core\evaluation.py", line 118, in run_with_timeout_and_stack return request()
File "c:\temp\mathics\lib\site-packages\mathics\core\evaluation.py", line 354, in evaluate return self.format_output(self.last_eval, format)
File "c:\temp\mathics\lib\site-packages\mathics_django\web\models.py", line 32, in <lambda> evaluation.format_output = lambda expr, format: format_output(
File "c:\temp\mathics\lib\site-packages\mathics_django\web\format.py", line 69, in format_output use_quotes = get_settings_value(obj.definitions, "Settings`$QuotedStrings")
File "c:\temp\mathics\lib\site-packages\mathics\session.py", line 37, in get_settings_value return definitions.get_ownvalue(setting_name).replace.to_python(string_quotes=False) AttributeError: 'NoneType' object has no attribute 'replace'

About Page:

Software information
Django: 3.2.5
three.js: r124
MathJax: 2.7.9
Mathics: 3.1.0
Mathics Django: 3.1.0
mpmath: 1.2.1
Numpy: 3.1.0
Python: CPython 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
Sympy: 1.8
Settings
Settings`$PreferredBackendMethod: "sympy"
This sets whether to use mpmath, numpy or Sympy for numeric and symbolic constants and methods, when there is a choice.
Settings`$QuotedStrings: Settings`$QuotedStrings
System`MessageName[Settings`$QuotedStrings, "usage"]
Settings`$TraceGet: 
If this Boolean variable is set True, 'Get' traces the lines it reads that start a new expression.
System information
User Name: egonr
Process ID: 3084
System Time Zone: 1.0
File Paths
Base Directory: c:\temp\mathics\lib\site-packages\mathics
Home Directory: C:\Users\egonr
Installation Directory: c:\temp\mathics\lib\site-packages\mathics
Root Directory: \
Temporary Directory: C:\Users\egonr\AppData\Local\Temp
Database File: C:/Users/egonr/AppData/Roaming/Python/Mathics/mathics.sqlite
Document XML Data: C:/Users/egonr/AppData/Roaming/Python/Mathics/doc_xml_data.pcl
Machine information
Machine Name: DESKTOP-K763R4E
Machine: win32
Processor Type: AMD64
Memory Available: -1
System Memory: -1
Machine Precision: 15.954589770191003
Connection Information
HTTP User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Remote User:
Remote Address: 127.0.0.1
Remote Host:
rocky commented 2 years ago

From this, it looks like the Mathics-Django's settings file autoload/settings.m is not read in. I guess that would be under c:/Users/egonr/AppData/Roaming/Python/Mathics/ but I'll have to check on a Windows box when I have one running.

This might be a be a packaging problem and I'll look for that. A new release will be coming up relatively soon, so I will check specifically for these things.

A workaround is to set Settings`$QuotedStrings = True inside the session.

rocky commented 2 years ago

There were basically 2 bugs here.

Finally, let me say that although there was a weakness in Mathics core, since this was a Django problem that repository probably would have been the better place to report this. Or if you felt this was a mathics-omnibus problem, there is an issue tracker for that as well.