• Wez Furlong's avatar
    fix a python 2.7 vs 3 compat issue with exec · 5a9eb01a
    Wez Furlong authored
    Summary:
    This is a bit of a tricky issue; here's the bug in python 2.7
    that prevents using the function-like syntax:
    https://bugs.python.org/issue21591
    
    The nature of this bug is that scoped exec only works with nested functions
    when using the `exec` statement in 2.7.   That is a syntax error in python 3,
    which only allows using the `exec` function.
    
    To make the function syntax work in 2.7 we therefore need to avoid using
    lambdas or nested functions and have to resort to using a global variable
    to act as the "closure".
    
    Refs: https://github.com/facebook/watchman/pull/639
    
    Reviewed By: snarkmaster
    
    Differential Revision: D9552413
    
    fbshipit-source-id: a2cb9d325e18fb6fb06b9e284a84f0a0c80cfe7e
    5a9eb01a
utils.py 2.77 KB