Opened 18 months ago

#3648 new defect

steps/master.py:... DeprecationWarning: Argument strings and environment keys/values passed to reactor.spawnProcess should be str, not unicode.

Reported by: dcoshea Owned by:
Priority: minor Milestone: undecided
Version: 0.8.12 Keywords: unicode eight encoding properties
Cc:

Description

When a function is passed for the extract_fn parameter to SetPropertyFromCommand, that function is passed unicode strings, so is likely to return unicode strings too, but MasterShellCommand triggers a warning from twisted when those properties containing unicode strings are interpolated into command lines.

With Buildbot 0.8.12 running under Python 2.6 on CentOS 6, when I include these steps in a BuildFactory:

    def my_extract_fn(exit_status, stdout, stderr):
        return {"my_prop": stdout}

    f.addStep(shell.SetPropertyFromCommand(
        command="echo TEST_VALUE",
        extract_fn=my_extract_fn))

    f.addStep(master.MasterShellCommand(Interpolate("echo %(prop:my_prop:~NO_VALUE)s")))

twistd.log shows:

2016-11-29 14:39:57+1030 [-] releaseLocks(<buildbot.steps.shell.SetPropertyFromCommand object at 0x7f2334069cd0>): []
2016-11-29 14:39:57+1030 [-]  step 'setproperty' complete: success
2016-11-29 14:39:57+1030 [-] /drv1/buildbot/buildbot/src/buildbot/master/buildbot/steps/master.py:160: exceptions.DeprecationWarning: Argument strings and environment keys/values passed to reactor.spawnProcess should be str, not unicode.
2016-11-29 14:39:58+1030 [-] releaseLocks(<buildbot.steps.master.MasterShellCommand object at 0x7f231c09d190>): []

I can see from adding debugging output that my_extract_fn() is being passed unicode strings for stdout and stderr.

The above is with Twisted 13.1.0.

I can't reproduce this problem with 0.9.1 with Python 2.7 and Twisted 16.6.0, even though the newer version of Twisted has the same checks, so I assume this has been addressed somewhere in the nine branch within Buildbot.

This issue can be worked around by converting the strings back from unicode, e.g.:

        return {"my_prop": str(stdout)}

Presumably it wouldn't be so easy if the string was non-ASCII.

Change History (0)

Note: See TracTickets for help on using tickets.