diff options
author | Darragh Bailey <dbailey@hpe.com> | 2016-01-11 17:58:17 +0000 |
---|---|---|
committer | Darragh Bailey <dbailey@hpe.com> | 2016-01-11 18:35:20 +0000 |
commit | e1f5dec356ea13d5f838926f939d95835d4b5873 (patch) | |
tree | d94f38ff25f4aba01c6256fc9647b1853966d302 /jenkins_jobs/builder.py | |
parent | 71449dbed9923f59677b9732719cf30eb6a8dfe0 (diff) | |
download | python-jenkins-job-builder-e1f5dec356ea13d5f838926f939d95835d4b5873.tar.gz python-jenkins-job-builder-e1f5dec356ea13d5f838926f939d95835d4b5873.tar.xz python-jenkins-job-builder-e1f5dec356ea13d5f838926f939d95835d4b5873.zip |
Wrap stdout object only once with wrap_stream
Make sure to perform wrap external to loop, as otherwise this will
recursively wrap the output object and potentially result in getattr
lookups exceeding the recursion limit in python.
Change-Id: Ie9318a3d23a721e62c16e7b05f52d5b9bec1bb82
Diffstat (limited to 'jenkins_jobs/builder.py')
-rw-r--r-- | jenkins_jobs/builder.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/jenkins_jobs/builder.py b/jenkins_jobs/builder.py index e377f610..7dcdb8cb 100644 --- a/jenkins_jobs/builder.py +++ b/jenkins_jobs/builder.py @@ -350,12 +350,15 @@ class Builder(object): raise if output: + # ensure only wrapped once + if hasattr(output, 'write'): + output = utils.wrap_stream(output) + for job in self.parser.xml_jobs: if hasattr(output, 'write'): # `output` is a file-like object logger.info("Job name: %s", job.name) logger.debug("Writing XML to '{0}'".format(output)) - output = utils.wrap_stream(output) try: output.write(job.output()) except IOError as exc: |