UnboundLocalError when returning a variable : <p>I have a static method that collects some things together and returns them.</p>

<pre><code>@staticmethod
def testForMetrics(....):
    ...
    ...

    coverages = Metrics.findCoverageStats(....)

    ...
    return coverages, ....
</code></pre>

<p>findCoverageStats looks like</p>

<pre><code>@staticmethod
def findCoverageStats(....)
    coverages = {}

    ...# fill coverages with calculations

    return coverages
</code></pre>

<p>Running tells me <code>UnboundLocalError: local variable 'coverages' referenced before assignment</code>, but only in very rare cases.</p>

<p>What sort of edge cases could cause cause this behavior?</p>
