facebookarchive / bistro

Bistro is a flexible distributed scheduler, a high-performance framework supporting multiple paradigms while retaining ease of configuration, management, and monitoring.
https://bistro.io
MIT License
1.03k stars 158 forks source link

Use exec() function in both Python 2 and Python 3 #36

Closed cclauss closed 5 years ago

cclauss commented 5 years ago

Legacy exec statements are syntax errors in Python 3 but exec() function works as expected in both Python 2 and Python 3.

This PR attempts to solve a corner case described in https://github.com/facebook/bistro/pull/34#issuecomment-513992204 where having a dict comprehension inside an exec() function call can be problematic.

@snarkmaster

snarkmaster commented 5 years ago

I'll be merging this promptly.

I had to further fix this up since the patch still didn't pass the test case I gave on the prior PR:

$ ./cmake/targets_to_cmake_lists.py .
  File "./cmake/targets_to_cmake_lists.py", line 166
    exec(s, fn_locals)
SyntaxError: unqualified exec is not allowed in function 'parse_targets' it contains a nested function with free variables
facebook-github-bot commented 5 years ago

@snarkmaster merged this pull request in facebook/bistro@4fe8870da81a6b94fd9bec2a55368c9d070943a0.