@@ -82,13 +82,8 @@ def __init__(
8282 )
8383 except PyMathicsLoadException as e :
8484 raise
85- # print(e.module + " is not a valid pymathics module.")
86- #continue
8785 except ImportError as e :
8886 raise
89- #print(e.__repr__())
90- #continue
91- # print(module + loaded_module.pymathics_version_data['version'] + " by " + loaded_module.pymathics_version_data['author'])
9287
9388 if builtin_filename is not None :
9489 builtin_file = open (builtin_filename , "wb" )
@@ -167,17 +162,13 @@ def load_pymathics_module(self, module, remove_on_quit=True):
167162 def clear_pymathics_modules (self ):
168163 from mathics .builtin import builtins , builtins_by_module
169164
170- # Remove all modules that are not in mathics
171- # print("cleaning pymathics modules")
172165 for key in list (builtins_by_module .keys ()):
173166 if not key .startswith ("mathics." ):
174- print (f'removing module "{ key } " not in mathics.' )
175167 del builtins_by_module [key ]
176168 for key in pymathics :
177169 del self .pymathics [key ]
178170
179171 self .pymathics = {}
180- # print("everything is clean")
181172 return None
182173
183174 def clear_cache (self , name = None ):
@@ -416,10 +407,14 @@ def get_definition(self, name, only_if_exists=False) -> "Definition":
416407 builtin = self .builtin .get (name , None )
417408
418409 candidates = [user ] if user else []
410+ builtin_instance = None
419411 if pymathics :
412+ builtin_instance = pymathics
420413 candidates .append (pymathics )
421414 if builtin :
422415 candidates .append (builtin )
416+ if builtin_instance is None :
417+ builtin_instance = builtin
423418
424419 definition = candidates [0 ] if len (candidates )== 1 else None
425420 if len (candidates )> 0 and not definition :
@@ -456,6 +451,7 @@ def get_definition(self, name, only_if_exists=False) -> "Definition":
456451 options = options ,
457452 nvalues = sum ((c .nvalues for c in candidates ),[]),
458453 defaultvalues = sum ((c .defaultvalues for c in candidates ),[]),
454+ builtin = builtin_instance
459455 )
460456
461457 if definition is not None :
0 commit comments