When Arch’s python command selected Python 3, Python 2 programs needed an explicit interpreter name. #!/usr/bin/python2 was a reasonable way to ask for the latest installed Python 2 without pinning the minor version.
Pygments’ Python lexer did not recognize that shape. Its pattern allowed an optional 2.X suffix, but the 2 could not appear without the dot and digit. I reported it.
The fix changed the nesting of one optional group:
-r'pythonw?(2\.\d)?'
+r'pythonw?(2(\.\d)?)?'The outer group still allowed no version. Inside the Python 2 alternative, the minor-version suffix became optional too. The accepted forms now included python2 alongside python and python2.7.
This was syntax detection, not interpreter selection. The shell already knew which program to execute. The highlighter’s approximation of executable names had failed to keep up with the naming convention the script used.
Georg Brandl made the fix. I reported the missing form and why the python2 spelling had become useful.