[Python-ideas] Make py.exe default to Python 3
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Mar 9 16:20:21 EST 2016
On 09/03/2016 13:21, Paul Moore wrote:
> On 9 March 2016 at 12:49, eryk sun <eryksun at gmail.com> wrote:
>> On Wed, Mar 9, 2016 at 3:47 AM, Paul Moore <p.f.moore at gmail.com> 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
I do not believe that this needs a PEP, a tracker item should be fine
IMHO. We should just ensure that the original authors of the PEP are
aware, as missing out their opinions would be a disservice to the Python
Windows community, as small as that may be when compared to *nix.
Just my £0.02p worth.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-ideas
mailing list