Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit a802923

Browse files
committed
Trac #25488: handle Sage values (like elements of QQbar) whose print representation can't be parsed
1 parent b557a97 commit a802923

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sage/interfaces/kash.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,16 @@ def _sage_(self, locals={}, *args):
792792

793793
string = self._sage_repr()
794794

795+
i = 1
796+
parsedict = {}
795797
for key,val in locals.items():
796-
string = string.replace(str(key), str(val))
798+
name = 'sage' + str(i)
799+
string = string.replace(str(key), name)
800+
parsedict[name] = val
801+
i = i + 1
797802

798803
try:
799-
return sage_eval(string, locals={str(v):v for v in locals.values()})
804+
return sage_eval(string, locals=parsedict)
800805
except Exception:
801806
raise NotImplementedError("Unable to parse output: %s" % string)
802807

0 commit comments

Comments
 (0)