brownplt / lambda-py

Other
58 stars 10 forks source link

return from except clause gives SyntaxError exception #39

Closed amtriathlon closed 11 years ago

amtriathlon commented 11 years ago

For example, using ___assertRaises definition from py-prelude.py:

def ___assertRaises(e, f, *args):
  try:
    f(*args)
  except e as the_exn:
    return
  else:
    assert(False)
  assert(False)

def check(x):
    if not x:
        raise KeyError
    else:
        return x

___assertRaises(KeyError, check, 0)

gives:

SyntaxError: 'return' outside function
amtriathlon commented 11 years ago

Solved in https://github.com/brownplt/lambda-py/commit/a48cccb36faf050c022657c8e6f7a24389eec86f