]> www.ginac.de Git - ginac.git/commitdiff
Convert YAPTU to Python3.
authorRichard Kreckel <kreckel@ginac.de>
Sun, 17 Feb 2019 19:43:28 +0000 (20:43 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Sun, 17 Feb 2019 19:43:28 +0000 (20:43 +0100)
It should now work with python2 and python3.

scripts/yaptu.py

index ddf18f5013eeb202c1907264da71a0ec266479f6..cffb19050ce6d1272e9dae94ebfc4a52c7ee131b 100644 (file)
@@ -33,7 +33,7 @@ class copier:
         def repl(match, self=self):
             "return the eval of a found expression, for replacement"
             # uncomment for debug:
         def repl(match, self=self):
             "return the eval of a found expression, for replacement"
             # uncomment for debug:
-           # print '!!! replacing',match.group(1)
+            # print '!!! replacing',match.group(1)
             expr = self.preproc(match.group(1), 'eval')
             try: return str(eval(expr, self.globals, self.locals))
             except: return str(self.handle(expr))
             expr = self.preproc(match.group(1), 'eval')
             try: return str(eval(expr, self.globals, self.locals))
             except: return str(self.handle(expr))
@@ -65,8 +65,8 @@ class copier:
                 stat = self.preproc(stat, 'exec')
                 stat = '%s _cb(%s,%s)' % (stat,i+1,j)
                 # for debugging, uncomment...:
                 stat = self.preproc(stat, 'exec')
                 stat = '%s _cb(%s,%s)' % (stat,i+1,j)
                 # for debugging, uncomment...:
-               # print "-> Executing: {"+stat+"}"
-                exec stat in self.globals,self.locals
+                # print "-> Executing: {"+stat+"}"
+                exec(stat, self.globals, self.locals)
                 i=j+1
             else:       # normal line, just copy with substitution
                 self.ouf.write(self.regex.sub(repl,line))
                 i=j+1
             else:       # normal line, just copy with substitution
                 self.ouf.write(self.regex.sub(repl,line))