You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetVersion failed for me under python3, because it relies on the exec operation modifying the locals of GetVersion. According to python docs, code executed by exec(str) can read the function's locals but modifications to them may not work.
The fix is to create a namespace and to read the result from the namespace (which is a good idea whenever exec is used; but here we need to avoid python2's syntax 'exec expr in ns' in order to be python 3 compatible.)
As I understand it, python 2 normally 'compiles' functions so that the locals aren't in a dictionary, eliminating name lookups; supporting exec requires functions using exec to be compiled quite differently. I guess that was dropped in python3, and exec now fabricates a 'locals' dictionary, to support local access, but it can't propagate changes back (in particular, the exec function can't create locals which did not exist in the function at 'compile time').
I did a PR but I'm not going to sign a CLA for 4 lines of code. So instead here it is.
In GetVersion() change everything below the 'with' to something along the lines of
GetVersion failed for me under python3, because it relies on the exec operation modifying the locals of GetVersion. According to python docs, code executed by exec(str) can read the function's locals but modifications to them may not work.
The fix is to create a namespace and to read the result from the namespace (which is a good idea whenever exec is used; but here we need to avoid python2's syntax 'exec expr in ns' in order to be python 3 compatible.)
As I understand it, python 2 normally 'compiles' functions so that the locals aren't in a dictionary, eliminating name lookups; supporting exec requires functions using exec to be compiled quite differently. I guess that was dropped in python3, and exec now fabricates a 'locals' dictionary, to support local access, but it can't propagate changes back (in particular, the exec function can't create locals which did not exist in the function at 'compile time').
I did a PR but I'm not going to sign a CLA for 4 lines of code. So instead here it is.
In GetVersion() change everything below the 'with' to something along the lines of
The text was updated successfully, but these errors were encountered: