On 9 March 2016 at 12:49, eryk sun
On Wed, Mar 9, 2016 at 3:47 AM, Paul Moore
wrote: I don't disagree with limiting the change to not affect unversioned shebang lines, but I'm not sure how much effort I'd personally be willing to put into special-casing that. We can see on that one when I start to look at the actual code, I guess...
I agree with Nick that Python 2 compatibility should be maintained for virtual paths in shebangs. I think a straight-forward solution is for locate_python() to gain a "virtual_mode" BOOL parameter, which is TRUE only when processing a virtual shebang, i.e. when called from maybe_handle_shebang(). For example, when wanted_ver is empty, locate_python would search the following sequence:
configured_value = get_configured_value(config_key); if (configured_value) result = find_python_by_version(configured_value); if (result == NULL) result = find_python_by_version(virtual_mode ? L"2" : L"3"); if (result == NULL) result = find_python_by_version(virtual_mode ? L"3" : L"2");
This change works for me with various combinations of enabled PythonCore registry keys, PY_PYTHON values, and shebang lines. Note that the behavior of the plain "#!python" virtual shebang gets lumped in with virtual Unix paths, but I don't know why anyone would add this shebang without a target version.
Thanks for reviewing the code for me - that does indeed look perfectly straightforward so I'm OK with following Nick's suggestion here. As there's not been much in the way of resistance to the proposal, do people think it requires a PEP? I plan on letting this thread run its course either way, it's just a matter of whether the next step should be a tracker item or a PEP. Thanks, Paul