Skip to content

Commit 12fea19

Browse files
committed
Fix asy output for compabitibility with the doc generator. In , catch possible fail in os.getlogin()
1 parent 7857d42 commit 12fea19

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

mathics/builtin/graphics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,7 @@ def boxes_to_tex(self, leaves, forxml=False, **options):
31943194
if forxml:
31953195
return (tex, width, height)
31963196
else:
3197-
return "\n\\begin{asy}\n" + tex + "\n\\end{asy}"
3197+
return "\n\\begin{asy}\n" + tex + "\n\\end{asy}\n"
31983198

31993199
def boxes_to_xml(self, leaves, **options):
32003200
evaluation = options.get("evaluation", None)

mathics/builtin/system.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,16 @@ class UserName(Predefined):
406406

407407
name = "$UserName"
408408

409+
messages = {
410+
'nologin': "UserName not available in this system.",
411+
}
412+
409413
def evaluate(self, evaluation) -> String:
410-
return String(os.getlogin())
414+
try:
415+
return String(os.getlogin())
416+
except:
417+
evaluation.message('$UserName', 'nologin')
418+
return
411419

412420

413421
class Version(Predefined):

0 commit comments

Comments
 (0)