From 3403c8748e5ba9f9b46df3abf1552f82ee5d4da0 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Dec 2013 18:05:45 +0000 Subject: [PATCH] Fix use of outdated exec and repr syntax --- .../distributed/DistributedObjectGlobalUD.py | 4 +- direct/src/distributed/MsgTypes.py | 2 +- direct/src/distributed/MsgTypesCMU.py | 2 +- direct/src/particles/ParticleEffect.py | 2 +- direct/src/particles/Particles.py | 52 +++++++++---------- direct/src/pyinst/imputil.py | 2 +- direct/src/showutil/FreezeTool.py | 2 +- direct/src/tkpanels/FSMInspector.py | 2 +- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/direct/src/distributed/DistributedObjectGlobalUD.py b/direct/src/distributed/DistributedObjectGlobalUD.py index 8af8a0ecb8..c53f1cdde9 100755 --- a/direct/src/distributed/DistributedObjectGlobalUD.py +++ b/direct/src/distributed/DistributedObjectGlobalUD.py @@ -35,7 +35,7 @@ class DistributedObjectGlobalUD(DistributedObjectUD): def __execMessage(self, message): if not self.ExecNamespace: # Import some useful variables into the ExecNamespace initially. - exec 'from pandac.PandaModules import *' in globals(), self.ExecNamespace + exec('from pandac.PandaModules import *', globals(), self.ExecNamespace) #self.importExecNamespace() # Now try to evaluate the expression using ChatInputNormal.ExecNamespace as @@ -48,7 +48,7 @@ class DistributedObjectGlobalUD(DistributedObjectUD): # "import math". These aren't expressions, so eval() # fails, but they can be exec'ed. try: - exec message in globals(), self.ExecNamespace + exec(message, globals(), self.ExecNamespace) return 'ok' except: exception = sys.exc_info()[0] diff --git a/direct/src/distributed/MsgTypes.py b/direct/src/distributed/MsgTypes.py index 4f6340aae2..283701e3b4 100644 --- a/direct/src/distributed/MsgTypes.py +++ b/direct/src/distributed/MsgTypes.py @@ -108,7 +108,7 @@ MsgId2Names = invertDictLossless(MsgName2Id) # put msg names in module scope, assigned to msg value for name, value in MsgName2Id.items(): - exec '%s = %s' % (name, value) + exec('%s = %s' % (name, value)) del name, value # These messages are ignored when the client is headed to the quiet zone diff --git a/direct/src/distributed/MsgTypesCMU.py b/direct/src/distributed/MsgTypesCMU.py index 32e70d68fd..8501866a5b 100644 --- a/direct/src/distributed/MsgTypesCMU.py +++ b/direct/src/distributed/MsgTypesCMU.py @@ -27,5 +27,5 @@ MsgId2Names = invertDictLossless(MsgName2Id) # put msg names in module scope, assigned to msg value for name, value in MsgName2Id.items(): - exec '%s = %s' % (name, value) + exec('%s = %s' % (name, value)) del name, value diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py index 25e0343ddb..914630f19c 100644 --- a/direct/src/particles/ParticleEffect.py +++ b/direct/src/particles/ParticleEffect.py @@ -202,7 +202,7 @@ class ParticleEffect(NodePath): data = vfs.readFile(filename, 1) data = data.replace('\r', '') try: - exec data + exec(data) except: self.notify.warning('loadConfig: failed to load particle file: '+ repr(filename)) raise diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py index 4a065fe709..974ff4af9e 100644 --- a/direct/src/particles/Particles.py +++ b/direct/src/particles/Particles.py @@ -365,31 +365,31 @@ class Particles(ParticleSystem): typ = type(fun).__name__ if typ == 'ColorInterpolationFunctionConstant': c_a = fun.getColorA() - file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),'+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionLinear': c_a = fun.getColorA() c_b = fun.getColorB() - file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),'+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionStepwave': c_a = fun.getColorA() c_b = fun.getColorB() w_a = fun.getWidthA() w_b = fun.getWidthB() - file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - repr(w_a)+','+`w_b`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),' + \ + repr(w_a)+','+repr(w_b)+','+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionSinusoid': c_a = fun.getColorA() c_b = fun.getColorB() per = fun.getPeriod() - file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - repr(per)+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),' + \ + repr(per)+','+repr(mod)+')\n') elif (self.rendererType == "SparkleParticleRenderer"): file.write('# Sparkle parameters\n') @@ -468,31 +468,31 @@ class Particles(ParticleSystem): typ = type(fun).__name__ if typ == 'ColorInterpolationFunctionConstant': c_a = fun.getColorA() - file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),'+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionLinear': c_a = fun.getColorA() c_b = fun.getColorB() - file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),'+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionStepwave': c_a = fun.getColorA() c_b = fun.getColorB() w_a = fun.getWidthA() w_b = fun.getWidthB() - file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - repr(w_a)+','+`w_b`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),' + \ + repr(w_a)+','+repr(w_b)+','+repr(mod)+')\n') elif typ == 'ColorInterpolationFunctionSinusoid': c_a = fun.getColorA() c_b = fun.getColorB() per = fun.getPeriod() - file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+`t_e`+','+ \ - 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - repr(per)+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+repr(t_e)+','+ \ + 'Vec4('+repr(c_a[0])+','+repr(c_a[1])+','+repr(c_a[2])+','+repr(c_a[3])+'),' + \ + 'Vec4('+repr(c_b[0])+','+repr(c_b[1])+','+repr(c_b[2])+','+repr(c_b[3])+'),' + \ + repr(per)+','+repr(mod)+')\n') file.write('# Emitter parameters\n') emissionType = self.emitter.getEmissionType() diff --git a/direct/src/pyinst/imputil.py b/direct/src/pyinst/imputil.py index 5c49f69b09..dadfe03900 100644 --- a/direct/src/pyinst/imputil.py +++ b/direct/src/pyinst/imputil.py @@ -223,7 +223,7 @@ class Importer: # execute the code within the module's namespace if not is_module: - exec result[1] in module.__dict__ + exec(result[1], module.__dict__) # insert the module into its parent if parent: diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index 089b91c2a9..4f0ac57ca4 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -657,7 +657,7 @@ class Freezer: __path__. """ str = 'import %s' % (moduleName) - exec str + exec(str) module = sys.modules[moduleName] for path in module.__path__: diff --git a/direct/src/tkpanels/FSMInspector.py b/direct/src/tkpanels/FSMInspector.py index 3ec7cafaaa..398cd1583f 100644 --- a/direct/src/tkpanels/FSMInspector.py +++ b/direct/src/tkpanels/FSMInspector.py @@ -71,7 +71,7 @@ class FSMInspector(AppShell): 'Set state label size', tearoff = 1) for size in (8, 10, 12, 14, 18, 24): menuBar.addmenuitem('Font Size', 'command', - 'Set font to: ' + repr(size) + ' Pts', label = `size` + ' Pts', + 'Set font to: ' + repr(size) + ' Pts', label = repr(size) + ' Pts', command = lambda s = self, sz = size: s.setFontSize(sz)) menuBar.addcascademenu('States', 'Marker Size', 'Set state marker size', tearoff = 1)