Subject: bug#43298: 27.1; Do font locking for Python 3, not 2

From: Kévin Le Gouguec <[email-masked]>
Date: Thu, 10 Sep 2020 19:23:18 +0200

This is one of my long-standing pet peeves, thanks for filing an issue
about it.  FWIW here is how I thought I'd go about fixing this Whenever
I'd Find The Time™ (… needless to say, if anyone wants to beat me to it,
there'll be no hard feelings):

1. Add fontification tests for the current fontification.
   (Because I expected the overall patch to be quite big, and I figured
   it'd be easier to get it merged if it came with a bunch of
   non-regression tests.)

2. Create 3 sets of font-lock settings in python.el: -2, -3, and
   -undecided (= whatever the current settings do).

3. Add a variable to control which settings to use (settable through
   Customize or through file/directory-local variables).

4. Add heuristics to pick the "right" style by default (e.g. look for a
   shebang).

On the one hand, I agree that Emacs should be py3k-compliant by now
out-of-the-box.  On the other hand, I'd bet there are a lot of poor
souls out there who will be stuck maintaining Python 2 code for a few
more years.  Messing with font-lock without giving them an escape hatch
sounds like some form of double-jeopardy…