Skip to content

Commit

Permalink
Fix produce_latex_macro with Python 3.13
Browse files Browse the repository at this point in the history
After PEP 667 implementation [1] locals() changes within an exec call are not propagated

[1] python/cpython@b034f14
  • Loading branch information
antonio-rojas committed Dec 21, 2024
1 parent e7477f8 commit 5d55dcc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sage/misc/latex_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ def produce_latex_macro(name, *sample_args):
count += 1
args += str(x) + ','
args += ')'
exec('from ' + module + ' import ' + real_name)
loc = locals()
exec('from ' + module + ' import ' + real_name, locals = loc)
if count:
defn = '[' + str(count) + ']{'
defn += eval('str(LatexCall()(' + real_name + args + '))') + '}'
defn += eval('str(LatexCall()(' + real_name + args + '))', locals = loc) + '}'
else:
defn = '{' + eval('str(LatexCall()(' + real_name + '))') + '}'
defn = '{' + eval('str(LatexCall()(' + real_name + '))', locals = loc) + '}'
count = 0
for x in sample_args:
count += 1
Expand Down

0 comments on commit 5d55dcc

Please sign in to comment.