-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment of N makes Mathics crash #210
Comments
From a pure programming standpoint, you don't add It sounds like a good high-level solution is something more along the lines about checking whether the lhs is a protected function as you observe rather than a more low-level solution about whether some sort of element is compound or not. |
Since the error is the missing |
@adamantinum I'm not sure if that makes sense, if I understand correctly this is happening with only special symbols, and they really shouldn't be re-assigned because the core of Mathics uses them, for example, any type of graphics would not work without N, it is kinda like if Python allowed I believe this should be something like the following: if not lhs.hasattr("leaves"):
return evaluation.warning("You really shouldn't do this") (warning: pseudo-code above) |
As far as I tried it happens only with N, if I run e.g. |
@adamantinum with "do the job" it lets the user assign or show the warning? Anyway, if you could make a PR to we test, that'd be great. @rocky @mmatera this is showing that something is really wrong, N should be like any symbol. I don't know even the place to look for this, do you have an idea? |
It means it returns the warning N is a protected symbol, as it does for any other Mathics symbol. |
I am working on it. I hope to have it later today. |
That's perfect, with the PR it works as it should do. Is there a reason why N behaves differently from other Symbols? @TiagoCavalcante regarding the place where looking for things like that, isn't there a manual or a scheme of how mathics code is organized? |
@adamantinum yes, there is buy it isn't that complete, anyway that isn't necessary as mmatera fixed it. |
Yes, I've seen the PR. |
Assignments such as
N = 1
make Mathics crash because lhs has no attribute leaves (file mathics/builtin/assignments/internals.py, line 399)I don't know if it be better to add an hasattr, as below, or a try-catch.
Obviously it could be useful call the rejected_because_protected function.
The text was updated successfully, but these errors were encountered: