test_jit.py: Replace direct `exec` invocation with a wrapper. (#15882)
authorMikhail Zolotukhin <mvz@fb.com>
Thu, 10 Jan 2019 00:57:22 +0000 (16:57 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 10 Jan 2019 01:01:20 +0000 (17:01 -0800)
commit159c2f39189bfb95a50548c008f40ac523fc752d
treeb1e02c8f136ed49cc804653e139318943f8cccd5
parentb28738ccb5b1cbf2c0ed3e6db5765aa4abc54ec3
test_jit.py: Replace direct `exec` invocation with a wrapper. (#15882)

Summary:
Python2 doesn't allow to invoke `exec` from a nested function:

  File "test/test_jit.py", line 4653
     exec(code, globals(), scope)
  SyntaxError: unqualified exec is not allowed in function 'test' it is a nested function

This patch wraps exec with a separate function, making it work for both python2
and python3.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15882

Differential Revision: D13614235

Pulled By: ZolotukhinM

fbshipit-source-id: 9a074308c2379f089402e0bf5a996cc649d6dbca
test/test_jit.py