Skip to content

Commit

Permalink
Enforce Property name and source as unicode or ascii string
Browse files Browse the repository at this point in the history
  • Loading branch information
benallard committed Nov 23, 2014
1 parent eca6bd3 commit 31398ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions master/buildbot/process/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def asList(self):
def asDict(self):
"""Return the properties as a simple key:value dictionary,
properly unicoded"""
return dict((util.ascii2unicode(k), (v, util.ascii2unicode(s)))
for k, (v, s) in self.properties.iteritems())
return dict((k, (v, s)) for k, (v, s) in self.properties.iteritems())

def __repr__(self):
return ('Properties(**' +
Expand Down Expand Up @@ -136,13 +135,15 @@ def hasProperty(self, name):
has_key = hasProperty

def setProperty(self, name, value, source, runtime=False):
name = util.ascii2unicode(name)
try:
json.dumps(value)
except TypeError:
warnings.warn(
"Non jsonable properties are not explicitly supported and" +
"will be explicitly disallowed in a future version.",
DeprecationWarning, stacklevel=2)
source = util.ascii2unicode(source)

self.properties[name] = (value, source)
if runtime:
Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ Changes and Removals
* The undocumented ``path`` parameter of the :bb:step:`MasterShellCommand` buildstep has been renamed ``workdir`` for better consistency with the other steps.
* The name and source of a Property have to be unicode or ascii string.
Changes for Developers
~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 31398ae

Please sign in to comment.