changeset 52742:f8f14e6d032b

py3: update the remaining shebang lines (mostly tests) to `python3` I noticed this when running `py hghave` on a system that still has Python2- the Windows launcher attempts to honor the version of python in the shebang, but `hghave` recently gained py3 type annotations, so that resulted in a SyntaxError. I guess CI has the compat shim installed to redirect `python` to `python3`, and maybe that's why nobody noticed. These were located by grepping for `#!.+python\b`. The remaining handful of cases are tests trying to find python files, which is fine as-is. The one thing to call out here is that apparently the RPM building hasn't worked with Python3 (or we've been getting lucky). `contrib/hg-ssh` has had a python3 shebang line since late 2020, which means the EOL anchor would have caused it to not match and not be replaced with `%{pythonexe}`. OTOH, it looks like that variable was used prior to the `hg-ssh` update in order to default to python3 (as opposed to using a specific /path/to/pythonX), and maybe the update to `hg-ssh` simply broke python2 builds. I'm not going to worry about this for now, since there are also direct calls to `setup.py`, which no longer work as of this release cycle. Somebody interested in RPMs can figure out all of the issues at once.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 30 Jan 2025 13:51:02 -0500
parents 48572371d478
children 8d4ec768aff4
files contrib/packaging/mercurial.spec contrib/python-zstandard/setup.py tests/dumbhttp.py tests/dummysmtpd.py tests/get-with-headers.py tests/hghave tests/test-filelog.py tests/test-highlight.t tests/test-remotefilelog-datapack.py tests/test-remotefilelog-histpack.py tests/test-status-inprocess.py tests/test-stdio.py tests/tinyproxy.py
diffstat 13 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/packaging/mercurial.spec	Tue Jan 07 14:05:51 2025 +0100
+++ b/contrib/packaging/mercurial.spec	Thu Jan 30 13:51:02 2025 -0500
@@ -91,7 +91,7 @@
 make all PYTHON=%{pythonexe}
 make -C contrib/chg
 
-sed -i -e '1s|#!/usr/bin/env python$|#!/usr/bin/env %{pythonexe}|' contrib/hg-ssh
+sed -i -e '1s|#!/usr/bin/env python3$|#!/usr/bin/env %{pythonexe}|' contrib/hg-ssh
 
 %install
 rm -rf $RPM_BUILD_ROOT
--- a/contrib/python-zstandard/setup.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/contrib/python-zstandard/setup.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (c) 2016-present, Gregory Szorc
 # All rights reserved.
 #
--- a/tests/dumbhttp.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/dumbhttp.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 
 """
--- a/tests/dummysmtpd.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/dummysmtpd.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """dummy SMTP server for use in tests"""
 
--- a/tests/get-with-headers.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/get-with-headers.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """This does HTTP requests (GET by default) given a host:port and path and
 returns a subset of the headers plus the body of the result."""
--- a/tests/hghave	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/hghave	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """Test the running system for features availability. Exit with zero
 if all features are there, non-zero otherwise. If a feature name is
 prefixed with "no-", the absence of feature is tested.
--- a/tests/test-filelog.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-filelog.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Tests the behavior of filelog w.r.t. data starting with '\1\n'
 """
--- a/tests/test-highlight.t	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-highlight.t	Thu Jan 30 13:51:02 2025 -0500
@@ -1010,7 +1010,7 @@
   > EOF
 
   $ cat > unknownfile << EOF
-  > #!/this/helps/pygments/detect/python
+  > #!/this/helps/pygments/detect/python3
   > def foo():
   >    pass
   > EOF
--- a/tests/test-remotefilelog-datapack.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-remotefilelog-datapack.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import hashlib
 import os
--- a/tests/test-remotefilelog-histpack.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-remotefilelog-histpack.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import hashlib
 import os
--- a/tests/test-status-inprocess.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-status-inprocess.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys
 
--- a/tests/test-stdio.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/test-stdio.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Tests the buffering behavior of stdio streams in `mercurial.utils.procutil`.
 """
--- a/tests/tinyproxy.py	Tue Jan 07 14:05:51 2025 +0100
+++ b/tests/tinyproxy.py	Thu Jan 30 13:51:02 2025 -0500
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 
 __doc__ = """Tiny HTTP Proxy.