Skip to content

Commit

Permalink
Merge pull request #44362 from Dr15Jones/fixEmptyFileInPathPython
Browse files Browse the repository at this point in the history
Fix how empty FileInPaths are handled in python
  • Loading branch information
cmsbuild authored Mar 10, 2024
2 parents 92eedea + 4f6cf22 commit c90f14e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion FWCore/ParameterSet/python/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def insertInto(self, parameterSet, myname):
parameterSet.addESInputTag(self.isTracked(), myname, self.cppTag(parameterSet))

class FileInPath(_SimpleParameterTypeBase):
def __init__(self,value):
def __init__(self,value=""):
super(FileInPath,self).__init__(value)
@staticmethod
def _isValid(value):
Expand Down Expand Up @@ -2189,6 +2189,9 @@ def testEDAlias(self):
def testFileInPath(self):
f = FileInPath("FWCore/ParameterSet/python/Types.py")
self.assertEqual(f.configValue(), "'FWCore/ParameterSet/python/Types.py'")
f = FileInPath()
self.assertEqual(f.configValue(), "''")

def testSecSource(self):
s1 = SecSource("EmbeddedRootSource", fileNames = vstring("foo.root"))
self.assertEqual(s1.type_(), "EmbeddedRootSource")
Expand Down
4 changes: 1 addition & 3 deletions FWCore/ParameterSet/src/ParameterDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,7 @@ namespace edm {

template <>
void writeSingleValue<FileInPath>(std::ostream& os, FileInPath const& value, ValueFormat) {
if (not value.relativePath().empty()) {
os << "'" << value.relativePath() << "'";
}
os << "'" << value.relativePath() << "'";
}

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ vp = cms.VPSet(
e = cms.EventID(1, 2, 3),
er = cms.EventRange('1:2:3-4:5:6'),
et = cms.ESInputTag('', 'foo'),
f = cms.FileInPath(),
f = cms.FileInPath(''),
i = cms.int32(1),
l = cms.int64(1),
s = cms.string('a'),
Expand Down

0 comments on commit c90f14e

Please sign in to comment.