Subject: [bug#71672] [PATCH] python: Prefer python3 over python

From: "Zack Weinberg" <[email-masked]>
Date: Tue, 25 Feb 2025 10:14:55 -0500

On Mon, Feb 24, 2025, at 11:03 PM, Jacob Bachmeyer wrote:
> On 2/24/25 10:48, Karl Berry wrote:
>> [...]
>>
>> To be clear, the above suggested factoring-out won't (intentionally)
>> affect the behavior of AM_PATH_PYTHON, right? It will still look for
>> "python" first, and still do all the stuff it does. I want Automake
>> to stay as backward-compatible as possible.
>
> The problem is that Python did *not* stay backward-compatible and in
> the worst way:  running a program written for Python2 on a Python3
> interpreter can silently corrupt data if I understand correctly.

Yes. It takes some doing, but I *have* seen people write Python2
programs with this characteristic without knowing it.

> At minimum, a request for an unversioned python should raise a warning
> (if not an error:  "specify Python2 or Python3") and AM_PATH_PYTHON
> should probably be deprecated in favor of separate AM_PATH_PYTHON2 and
> AM_PATH_PYTHON3.

Agreed.  I would *like* to go a step farther and have AM_PATH_PYTHON*
bomb out if it detects that "python" on the PATH runs Python3, but
that would put us in direct conflict with a bunch of Linux distributions
so we probably shouldn't actually do that.

> I am insufficiently familiar with Python to say if we should have
> finer granularity than "Python3" and I am uncertain how compatible the
> different releases of Python3 actually are.

With all relatively recent Python 3 releases, you can have reasonably
high confidence that a program written against 3.x, that doesn't use third-
party Python libraries, will work correctly with 3.y where y > x.  The
only exception I know about is that the core Python devs recently decided
to start removing "old, unmaintained" modules from the standard library.
Also, I'm not sure how far back "relatively recent" extends.

The reverse is not true; a program written for 3.x is very likely to not
work at all with 3.z where z < x.  There have been a *lot* of shiny new
features added to the language in each 3.x release.

The compatibility story is much worse when third-party libraries are involved,
but that's not AM_PATH_PYTHON's problem.

zw