Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FWCore/ParameterSet changes for python3 compatibility #26025

Merged
merged 1 commit into from Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 5 additions & 9 deletions FWCore/ParameterSet/python/Config.py
Expand Up @@ -629,10 +629,7 @@ def extend(self,other,items=()):
self.extend(item)

#now create a sequence that uses the newly made items
for name in seqs.iterkeys():
seq = seqs[name]
#newSeq = seq.copy()
#
for name,seq in six.iteritems(seqs):
if id(seq) not in self._cloneToObjectDict:
self.__setattr__(name,seq)
else:
Expand All @@ -642,8 +639,7 @@ def extend(self,other,items=()):
#now put in proper bucket
newSeq._place(name,self)

for name in tasksToAttach.iterkeys():
task = tasksToAttach[name]
for name, task in six.iteritems(tasksToAttach):
self.__setattr__(name, task)

#apply modifiers now that all names have been added
Expand Down Expand Up @@ -1298,11 +1294,11 @@ def __init__(self,args):
self.__args = args
def __call__(self,obj):
params = {}
for k in self.__args.iterkeys():
for k in six.iterkeys(self.__args):
if hasattr(obj,k):
params[k] = getattr(obj,k)
_modifyParametersFromDict(params, self.__args, self._raiseUnknownKey)
for k in self.__args.iterkeys():
for k in six.iterkeys(self.__args):
if k in params:
setattr(obj,k,params[k])
else:
Expand Down Expand Up @@ -1676,7 +1672,7 @@ def testProcessInsertion(self):
def testProcessExtend(self):
class FromArg(object):
def __init__(self,*arg,**args):
for name in args.iterkeys():
for name in six.iterkeys(args):
self.__dict__[name]=args[name]

a=EDAnalyzer("MyAnalyzer")
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/python/DictTypes.py
Expand Up @@ -17,7 +17,7 @@ def __init__(self,*args,**kw):
else:
self.list = list(args[0].iterkeys())
return
self.list = list(super(SortedKeysDict,self).iterkeys())
self.list = list(six.iterkeys(super(SortedKeysDict,self)))

def __repr__(self):
meat = ', '.join([ '%s: %s' % (repr(key), repr(val)) for key,val in six.iteritems(self) ])
Expand Down
12 changes: 5 additions & 7 deletions FWCore/ParameterSet/python/Mixins.py
Expand Up @@ -656,13 +656,11 @@ def _itemsFromStrings(strings,converter):
return (converter(x).value() for x in strings)

def saveOrigin(obj, level):
#frame = inspect.stack()[level+1]
frame = inspect.getframeinfo(inspect.currentframe(level+1))
# not safe under old python versions
#obj._filename = frame.filename
#obj._lineNumber = frame.lineno
obj._filename = frame[0]
obj._lineNumber = frame[1]
frame = inspect.stack()[level+1]
if isinstance(frame,tuple): frame=frame[0] #python3 changes this to a tuple where the first thing is the frame
fInfo=inspect.getframeinfo(frame)
obj._filename = fInfo.filename
obj._lineNumber =fInfo.lineno

def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
if len(newParams):
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/python/SequenceTypes.py
Expand Up @@ -582,7 +582,7 @@ class Schedule(_ValidatingParameterListBase,_ConfigureComponent,_Unlabelable):
def __init__(self,*arg,**argv):
super(Schedule,self).__init__(*arg)
self._tasks = OrderedSet()
theKeys = argv.keys()
theKeys = list(argv.keys())
if theKeys:
if len(theKeys) > 1 or theKeys[0] != "tasks":
raise RuntimeError("The Schedule constructor can only have one keyword argument after its Path and\nEndPath arguments and it must use the keyword 'tasks'")
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/python/Types.py
Expand Up @@ -2,7 +2,7 @@
from .Mixins import PrintOptions, _SimpleParameterTypeBase, _ParameterTypeBase, _Parameterizable, _ConfigureComponent, _Labelable, _TypedParameterizable, _Unlabelable, _modifyParametersFromDict
from .Mixins import _ValidatingParameterListBase, specialImportRegistry
from .ExceptionHandling import format_typename, format_outerframe

from past.builtins import long

import copy
import math
Expand Down