2020from mathics .core .evaluation import Evaluation
2121from mathics .core .expression import Expression
2222from mathics .core .list import ListExpression
23+ from mathics .core .symbols import SymbolNull
2324from mathics .core .systemsymbols import (
2425 SymbolFailed ,
2526 SymbolNone ,
@@ -569,7 +570,6 @@ class SetEnvironment(Builtin):
569570
570571 Set a single environment variable:
571572 S> SetEnvironment["FOO" -> "bar"]
572- = SetEnvironment[FOO -> bar]
573573
574574 See that the environment variable has changed:
575575 S> GetEnvironment["FOO"]
@@ -587,18 +587,14 @@ class SetEnvironment(Builtin):
587587
588588 S> SetEnvironment["FOO" -> 5]
589589 : 5 must be a string or None.
590- = SetEnvironment[FOO -> 5]
590+ = $Failed
591591
592592 S> GetEnvironment["FOO"]
593593 = FOO -> baz
594594
595595 If the environment name is not a string, the evaluation fails without a message.
596596
597- S> SetEnvironment[FOO -> "bar"]
598- = SetEnvironment[FOO -> bar]
599-
600- S> GetEnvironment["FOO"]
601- = FOO -> baz
597+ S> SetEnvironment[1 -> "bar"]
602598
603599 See also <url>
604600 :'Environment':
@@ -615,14 +611,14 @@ def eval(self, rule, evaluation):
615611 env_var_name , env_var_value = rule .elements
616612 if not (env_var_value is SymbolNone or isinstance (env_var_value , String )):
617613 evaluation .message ("SetEnvironment" , "value" , env_var_value )
618- return None
614+ return SymbolFailed
619615
620616 if isinstance (env_var_name , String ):
621617 # WMA does not give an error message if env_var_name is not a String - weird.
622618 os .environ [env_var_name .value ] = (
623619 None if None is SymbolNone else env_var_value .value
624620 )
625- return None
621+ return SymbolNull
626622
627623 def eval_list (self , rules : Expression , evaluation : Evaluation ):
628624 "SetEnvironment[{rules__}]"
0 commit comments