# HG changeset patch # User Paul Boddie # Date 1480939281 -3600 # Node ID f484c01e190343edd847ad7b562a17996a35b2ea # Parent fc6b2c8370426162f2537920dbcd1081da0269ef Suppress return statements in module-level exception block completion code. diff -r fc6b2c837042 -r f484c01e1903 translator.py --- a/translator.py Mon Dec 05 01:42:42 2016 +0100 +++ b/translator.py Mon Dec 05 13:01:21 2016 +0100 @@ -1497,13 +1497,17 @@ self.writeline("{") self.indent += 1 - # Only use the normal return statement if no surrounding try blocks - # apply. + # Do not return anything at the module level. + + if self.get_namespace_path() != self.name: - if not self.in_try_finally and not self.in_try_except: - self.writeline("if (!__ISNULL(__tmp_exc.arg)) return __tmp_exc.arg;") - else: - self.writeline("if (!__ISNULL(__tmp_exc.arg)) __Throw(__tmp_exc);") + # Only use the normal return statement if no surrounding try blocks + # apply. + + if not self.in_try_finally and not self.in_try_except: + self.writeline("if (!__ISNULL(__tmp_exc.arg)) return __tmp_exc.arg;") + else: + self.writeline("if (!__ISNULL(__tmp_exc.arg)) __Throw(__tmp_exc);") self.indent -= 1 self.writeline("}")