Subject: bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters

From: kobarity <[email-masked]>
Date: Sun, 26 May 2024 23:15:50 +0900

Mattias Engdegård wrote:
> 
> 26 maj 2024 kl. 14.36 skrev kobarity <[email-masked]>:
> 
> > Sorry, I forgot that native completion does not work on Mac, even with
> > Python 3.  What I wanted to know is if there is unexpected echo backs
> > with Python 2 on Mac.
> 
> Not that I can see when running an interactive Python shell in Emacs, no.

Could you see what is returned when you enter the following line in
Inferior Python buffer running Python 2 on Mac?

__PYTHON_EL_eval("print(\"Hello\")\n", "")

> > Maybe it is better to prefer "python3", but I don't know if that would
> > reliably prevent the problem.  The best way would be to skip some
> > tests if the selected interpreter is Python 2 and it is running on
> > Mac.
> 
> Why select Python 2 in the first place? Is it more important to test Python 2 than Python 3 on other platforms?

I am not saying that Python 2 (or simple "python") should be the
first.  I do agree that "python3" should be preferred than "python".

My point is that we cannot assure that Python 2 is not selected.  One
example is EMACS_PYTHON_INTERPRETER environment variable introduced by
the patch.  It can specify the interpreter used in ERTs.  So a Mac
user may set EMACS_PYTHON_INTERPRETER to "python".

I wrote in the previous mail:

> As for EMACS_PYTHON_INTERPRETER, I am a little doubtful that it is the
> right thing to introduce.  It allows the ERT runner to specify the
> interpreter.  It's OK for ERTs that can be run on both Python 2 and 3,
> but you may want to write an ERT that can only be run on Python 3.

At the time of writing, I assumed that current ERTs can be run on both
Python 2 and 3 on all platforms.  However, it turned out that it was
wrong.  Some tests fail with Python 2 on Mac.  So I think we need some
mechanism to skip test based on the interpreter version and the
platform.