Skip to contentSkip to conversation

python: Explicit usage of Python 3

PATCH Applied Philippe Mathieu-Daudé 3 participants 17 messages Jan 30, 2020 – Mar 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover python: Explicit usage of Python 3

Hello,

These are mechanical sed patches used to convert the code base to Python 3, as suggested on this thread:
https://www.mail-archive.com/[email protected]/msg675024.html

Since v1:
- new checkpatch.pl patch
- addressed Kevin and Vladimir review comments
- added R-b/A-b tags

Regards,

Phil.

Philippe Mathieu-Daudé (12):
scripts/checkpatch.pl: Only allow Python 3 interpreter tests/qemu-iotests/check: Allow use of python3 interpreter tests/qemu-iotests: Explicit usage of Python 3 (scripts with __main__)
tests: Explicit usage of Python 3
scripts: Explicit usage of Python 3 (scripts with __main__) scripts/minikconf: Explicit usage of Python 3 tests/acceptance: Remove shebang header
scripts/tracetool: Remove shebang header
tests/vm: Remove shebang header
tests/qemu-iotests: Explicit usage of Python3 (scripts without

    __main__)

scripts: Explicit usage of Python 3 (scripts without __main__) tests/qemu-iotests/check: Only check for Python 3 interpreter

 scripts/analyse-9p-simpletrace.py                | 2 +-
 scripts/analyse-locks-simpletrace.py             | 2 +-
 scripts/checkpatch.pl                            | 6 ++++++
 scripts/decodetree.py                            | 2 +-
 scripts/device-crash-test                        | 2 +-
 scripts/kvm/kvm_flightrecorder                   | 2 +-
 scripts/minikconf.py                             | 1 +
 scripts/qapi-gen.py                              | 2 +-
 scripts/qmp/qemu-ga-client                       | 2 +-
 scripts/qmp/qmp                                  | 2 +-
 scripts/qmp/qmp-shell                            | 2 +-
 scripts/qmp/qom-fuse                             | 2 +-
 scripts/render_block_graph.py                    | 2 +-
 scripts/replay-dump.py                           | 2 +-
 scripts/simpletrace.py                           | 2 +-
 scripts/tracetool.py                             | 2 +-
 scripts/tracetool/__init__.py                    | 1 -
 scripts/tracetool/backend/__init__.py            | 1 -
 scripts/tracetool/backend/dtrace.py              | 1 -
 scripts/tracetool/backend/ftrace.py              | 1 -
 scripts/tracetool/backend/log.py                 | 1 -
 scripts/tracetool/backend/simple.py              | 1 -
 scripts/tracetool/backend/syslog.py              | 1 -
 scripts/tracetool/backend/ust.py                 | 1 -
 scripts/tracetool/format/__init__.py             | 1 -
 scripts/tracetool/format/c.py                    | 1 -
 scripts/tracetool/format/d.py                    | 1 -
 scripts/tracetool/format/h.py                    | 1 -
 scripts/tracetool/format/log_stap.py             | 1 -
 scripts/tracetool/format/simpletrace_stap.py     | 1 -
 scripts/tracetool/format/stap.py                 | 1 -
 scripts/tracetool/format/tcg_h.py                | 1 -
 scripts/tracetool/format/tcg_helper_c.py         | 1 -
 scripts/tracetool/format/tcg_helper_h.py         | 1 -
 scripts/tracetool/format/tcg_helper_wrapper_h.py | 1 -
 scripts/tracetool/format/ust_events_c.py         | 1 -
 scripts/tracetool/format/ust_events_h.py         | 1 -
 scripts/tracetool/transform.py                   | 1 -
 scripts/tracetool/vcpu.py                        | 1 -
 scripts/vmstate-static-checker.py                | 2 +-
 tests/acceptance/virtio_seg_max_adjust.py        | 1 -
 tests/acceptance/x86_cpu_model_versions.py       | 1 -
 tests/docker/travis.py                           | 2 +-
 tests/qapi-schema/test-qapi.py                   | 2 +-
 tests/qemu-iotests/030                           | 2 +-
 tests/qemu-iotests/040                           | 2 +-
 tests/qemu-iotests/041                           | 2 +-
 tests/qemu-iotests/044                           | 2 +-
 tests/qemu-iotests/045                           | 2 +-
 tests/qemu-iotests/055                           | 2 +-
 tests/qemu-iotests/056                           | 2 +-
 tests/qemu-iotests/057                           | 2 +-
 tests/qemu-iotests/065                           | 2 +-
 tests/qemu-iotests/093                           | 2 +-
 tests/qemu-iotests/096                           | 2 +-
 tests/qemu-iotests/118                           | 2 +-
 tests/qemu-iotests/124                           | 2 +-
 tests/qemu-iotests/129                           | 2 +-
 tests/qemu-iotests/132                           | 2 +-
 tests/qemu-iotests/136                           | 2 +-
 tests/qemu-iotests/139                           | 2 +-
 tests/qemu-iotests/147                           | 2 +-
 tests/qemu-iotests/148                           | 2 +-
 tests/qemu-iotests/149                           | 2 +-
 tests/qemu-iotests/151                           | 2 +-
 tests/qemu-iotests/152                           | 2 +-
 tests/qemu-iotests/155                           | 2 +-
 tests/qemu-iotests/163                           | 2 +-
 tests/qemu-iotests/165                           | 2 +-
 tests/qemu-iotests/169                           | 2 +-
 tests/qemu-iotests/194                           | 2 +-
 tests/qemu-iotests/196                           | 2 +-
 tests/qemu-iotests/199                           | 2 +-
 tests/qemu-iotests/202                           | 2 +-
 tests/qemu-iotests/203                           | 2 +-
 tests/qemu-iotests/205                           | 2 +-
 tests/qemu-iotests/206                           | 2 +-
 tests/qemu-iotests/207                           | 2 +-
 tests/qemu-iotests/208                           | 2 +-
 tests/qemu-iotests/209                           | 2 +-
 tests/qemu-iotests/210                           | 2 +-
 tests/qemu-iotests/211                           | 2 +-
 tests/qemu-iotests/212                           | 2 +-
 tests/qemu-iotests/213                           | 2 +-
 tests/qemu-iotests/216                           | 2 +-
 tests/qemu-iotests/218                           | 2 +-
 tests/qemu-iotests/219                           | 2 +-
 tests/qemu-iotests/222                           | 2 +-
 tests/qemu-iotests/224                           | 2 +-
 tests/qemu-iotests/228                           | 2 +-
 tests/qemu-iotests/234                           | 2 +-
 tests/qemu-iotests/235                           | 2 +-
 tests/qemu-iotests/236                           | 2 +-
 tests/qemu-iotests/237                           | 2 +-
 tests/qemu-iotests/238                           | 2 +-
 tests/qemu-iotests/242                           | 2 +-
 tests/qemu-iotests/245                           | 2 +-
 tests/qemu-iotests/246                           | 2 +-
 tests/qemu-iotests/248                           | 2 +-
 tests/qemu-iotests/254                           | 2 +-
 tests/qemu-iotests/255                           | 2 +-
 tests/qemu-iotests/256                           | 2 +-
 tests/qemu-iotests/257                           | 2 +-
 tests/qemu-iotests/258                           | 2 +-
 tests/qemu-iotests/260                           | 2 +-
 tests/qemu-iotests/262                           | 2 +-
 tests/qemu-iotests/264                           | 2 +-
 tests/qemu-iotests/266                           | 2 +-
 tests/qemu-iotests/277                           | 2 +-
 tests/qemu-iotests/280                           | 2 +-
 tests/qemu-iotests/281                           | 2 +-
 tests/qemu-iotests/check                         | 2 +-
 tests/qemu-iotests/nbd-fault-injector.py         | 2 +-
 tests/qemu-iotests/qcow2.py                      | 2 +-
 tests/qemu-iotests/qed.py                        | 2 +-
 tests/vm/basevm.py                               | 1 -
 tests/vm/centos                                  | 2 +-
 tests/vm/fedora                                  | 2 +-
 tests/vm/freebsd                                 | 2 +-
 tests/vm/netbsd                                  | 2 +-
 tests/vm/openbsd                                 | 2 +-
 tests/vm/ubuntu.i386                             | 2 +-
 122 files changed, 101 insertions(+), 120 deletions(-)
 mode change 100755 => 100644 tests/acceptance/virtio_seg_max_adjust.py
 mode change 100755 => 100644 tests/vm/basevm.py
Signature · 1 line
2.21.1
#1 lore raw

PATCH v2 1/12 scripts/checkpatch.pl: Only allow Python 3 interpreter

Since commit ddf9069963 QEMU requires Python >= 3.5.

PEP 0394 [*] states that 'python3' should be available and that 'python' is optional.

To avoid problem with unsupported versions, enforce the shebang interpreter to Python 3.

[*] https://www.python.org/dev/peps/pep-0394/

---
Cc: Eric Blake <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Wei Yang <[email protected]>

---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index 3aef6e3dfe..ce43a306f8 100755
@@ -1460,6 +1460,12 @@ sub process {
 			}
 		}
 
+# Only allow Python 3 interpreter
+		if ($realline == 1 &&
+			$line =~ /^\+#!\ *\/usr\/bin\/(?:env )?python$/) {
+			ERROR("please use python3 interpreter\n" . $herecurr);
+		}
+
 # Accept git diff extended headers as valid patches
 		if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) {
 			$is_patch = 1;
Signature · 1 line
2.21.1
#2 lore raw

PATCH v2 2/12 tests/qemu-iotests/check: Allow use of python3 interpreter

In reply to Philippe Mathieu-Daudé

As we want to enforce a unique and explicit Python 3 interpreter, we need let this script handle 'python3' too.

---
 tests/qemu-iotests/check | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +2 -1
index 2890785a10..bdcd64aea4 100755
@@ -825,7 +825,8 @@ do
 
         start=$(_wallclock)
 
-        if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
+        if [ "$(head -n 1 "$source_iotests/$seq" | sed 's/3$//')" \
+            == "#!/usr/bin/env python" ]; then
             if $python_usable; then
                 run_command="$PYTHON $seq"
             else
Signature · 1 line
2.21.1
#3 lore raw

PATCH v2 3/12 tests/qemu-iotests: Explicit usage of Python 3 (scripts with __main__)

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created mechanically by running:

  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
       $(git grep -l 'if __name__.*__main__')
---
 tests/qemu-iotests/030                   | 2 +-
 tests/qemu-iotests/040                   | 2 +-
 tests/qemu-iotests/041                   | 2 +-
 tests/qemu-iotests/044                   | 2 +-
 tests/qemu-iotests/045                   | 2 +-
 tests/qemu-iotests/055                   | 2 +-
 tests/qemu-iotests/056                   | 2 +-
 tests/qemu-iotests/057                   | 2 +-
 tests/qemu-iotests/065                   | 2 +-
 tests/qemu-iotests/093                   | 2 +-
 tests/qemu-iotests/096                   | 2 +-
 tests/qemu-iotests/118                   | 2 +-
 tests/qemu-iotests/124                   | 2 +-
 tests/qemu-iotests/129                   | 2 +-
 tests/qemu-iotests/132                   | 2 +-
 tests/qemu-iotests/136                   | 2 +-
 tests/qemu-iotests/139                   | 2 +-
 tests/qemu-iotests/147                   | 2 +-
 tests/qemu-iotests/148                   | 2 +-
 tests/qemu-iotests/151                   | 2 +-
 tests/qemu-iotests/152                   | 2 +-
 tests/qemu-iotests/155                   | 2 +-
 tests/qemu-iotests/163                   | 2 +-
 tests/qemu-iotests/165                   | 2 +-
 tests/qemu-iotests/169                   | 2 +-
 tests/qemu-iotests/196                   | 2 +-
 tests/qemu-iotests/199                   | 2 +-
 tests/qemu-iotests/205                   | 2 +-
 tests/qemu-iotests/245                   | 2 +-
 tests/qemu-iotests/257                   | 2 +-
 tests/qemu-iotests/258                   | 2 +-
 tests/qemu-iotests/281                   | 2 +-
 tests/qemu-iotests/nbd-fault-injector.py | 2 +-
 tests/qemu-iotests/qcow2.py              | 2 +-
 tests/qemu-iotests/qed.py                | 2 +-
 35 files changed, 35 insertions(+), 35 deletions(-)
tests/qemu-iotests/030 +1 -1
index 0990681c1e..aa911d266a 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for image streaming.
 #
tests/qemu-iotests/040 +1 -1
index 74f62c3c4a..2e7ee0e84f 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for image block commit.
 #
tests/qemu-iotests/041 +1 -1
index c07437fda1..219b120b57 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for image mirroring.
 #
tests/qemu-iotests/044 +1 -1
index 8b2afa2a11..7e99ea7c68 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests growing a large refcount table.
 #
tests/qemu-iotests/045 +1 -1
index 01cc038884..5acc89099c 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for fdsets and getfd.
 #
tests/qemu-iotests/055 +1 -1
index c732a112d6..82b9f5f47d 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for drive-backup and blockdev-backup
 #
tests/qemu-iotests/056 +1 -1
index f39287c162..f73fc74457 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for drive-backup
 #
tests/qemu-iotests/057 +1 -1
index 9fbba759b6..a8b4bb60e0 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for internal snapshot.
 #
tests/qemu-iotests/065 +1 -1
index 5b21eb96bd..6426474271 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test for additional information emitted by qemu-img info on qcow2
 # images
tests/qemu-iotests/093 +1 -1
index f03fa24a07..32ded11430 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for IO throttling
 #
tests/qemu-iotests/096 +1 -1
index ab9cb47822..5915f92786 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test that snapshots move the throttling configuration to the active
 # layer
tests/qemu-iotests/118 +1 -1
index e20080e9a6..adc8a848b5 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test case for the QMP 'change' command and all other associated
 # commands
tests/qemu-iotests/124 +1 -1
index d3e851e1ae..3705cbb6b3 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for incremental drive-backup
 #
tests/qemu-iotests/129 +1 -1
index cd6b9e9ce7..b0da4a5541 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests that "bdrv_drain_all" doesn't drain block jobs
 #
tests/qemu-iotests/132 +1 -1
index 0f2a106c81..39ea43067e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test mirror with unmap
 #
tests/qemu-iotests/136 +1 -1
index 012ea111ac..d59400c9fc 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for block device statistics
 #
tests/qemu-iotests/139 +1 -1
index cbb5a76530..6b1a444364 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test cases for the QMP 'blockdev-del' command
 #
tests/qemu-iotests/147 +1 -1
index 03fc2fabcf..51290829cd 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test case for NBD's blockdev-add interface
 #
tests/qemu-iotests/148 +1 -1
index 8c11c53cba..90931948e3 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test the rate limit of QMP events
 #
tests/qemu-iotests/151 +1 -1
index 76ae265cc1..f2df72c29c 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for active mirroring
 #
tests/qemu-iotests/152 +1 -1
index 732bf5f062..cc2ea09654 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for drive-mirror with source size unaligned to granularity
 #
tests/qemu-iotests/155 +1 -1
index e19485911c..e35b1d534b 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test whether the backing BDSs are correct after completion of a
 # mirror block job; in "existing" modes (drive-mirror with
tests/qemu-iotests/163 +1 -1
index d94728e080..5a3cc840a5 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for shrinking images
 #
tests/qemu-iotests/165 +1 -1
index 951ea011a2..b60a803dae 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for persistent dirty bitmaps.
 #
tests/qemu-iotests/169 +1 -1
index 9656a7f620..2c5a132aa3 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for dirty bitmaps migration.
 #
tests/qemu-iotests/196 +1 -1
index 92fe9244f8..e8fcf37273 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test clearing unknown autoclear_features flag by qcow2 after
 # migration. This test mimics migration to older qemu.
tests/qemu-iotests/199 +1 -1
index a2c8ecab5a..40774eed74 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for dirty bitmaps postcopy migration.
 #
tests/qemu-iotests/205 +1 -1
index 4bb2c21e8b..43432cb599 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for qmp command nbd-server-remove.
 #
tests/qemu-iotests/245 +1 -1
index d12b253065..489bf78bd0 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test cases for the QMP 'x-blockdev-reopen' command
 #
tests/qemu-iotests/257 +1 -1
index a9828251cf..004a433b8b 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test bitmap-sync backups (incremental, differential, and partials)
 #
tests/qemu-iotests/258 +1 -1
index b84cf02254..091755a45c 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Very specific tests for adjacent commit/stream block jobs
 #
tests/qemu-iotests/281 +1 -1
index 269d583b2c..0bf973bca6 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test cases for blockdev + IOThread interactions
 #
tests/qemu-iotests/nbd-fault-injector.py +1 -1
index 7e2dab6ea4..b158dd65a2 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # NBD server - fault injection utility
 #
 # Configuration file syntax:
tests/qemu-iotests/qcow2.py +1 -1
index 91e4420b9f..1c4fa2b09f 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import print_function
 import sys
tests/qemu-iotests/qed.py +1 -1
index 8adaaf46c4..36bca1de23 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tool to manipulate QED image files
 #
Signature · 1 line
2.21.1
#4 lore raw

PATCH v2 4/12 tests: Explicit usage of Python 3

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created mechanically by running:

  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
       $(git grep -l 'if __name__.*__main__')
---
 tests/docker/travis.py         | 2 +-
 tests/qapi-schema/test-qapi.py | 2 +-
 tests/vm/centos                | 2 +-
 tests/vm/fedora                | 2 +-
 tests/vm/freebsd               | 2 +-
 tests/vm/netbsd                | 2 +-
 tests/vm/openbsd               | 2 +-
 tests/vm/ubuntu.i386           | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)
tests/docker/travis.py +1 -1
index e1433012bd..62fccc5ebb 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Travis YAML config parser
 #
tests/qapi-schema/test-qapi.py +1 -1
index bad14edb47..503fb8ad25 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # QAPI parser test harness
 #
tests/vm/centos +1 -1
index f2f0befd84..a41ff109eb 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # CentOS image
 #
tests/vm/fedora +1 -1
index 8e270fc0f0..4d7d6049f4 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Fedora VM image
 #
tests/vm/freebsd +1 -1
index 33a736298a..fb54334696 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # FreeBSD VM image
 #
tests/vm/netbsd +1 -1
index ec6f3563b2..c5069a45f4 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # NetBSD VM image
 #
tests/vm/openbsd +1 -1
index d6173506f7..22cd9513dd 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # OpenBSD VM image
 #
tests/vm/ubuntu.i386 +1 -1
index 3834cd7a8d..48e9cb1ad3 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Ubuntu i386 image
 #
Signature · 1 line
2.21.1
#5 lore raw

PATCH v2 5/12 scripts: Explicit usage of Python 3 (scripts with __main__)

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created mechanically by running:

  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
       $(git grep -l 'if __name__.*__main__')
---
 scripts/analyse-locks-simpletrace.py | 2 +-
 scripts/decodetree.py                | 2 +-
 scripts/device-crash-test            | 2 +-
 scripts/kvm/kvm_flightrecorder       | 2 +-
 scripts/qapi-gen.py                  | 2 +-
 scripts/qmp/qemu-ga-client           | 2 +-
 scripts/qmp/qmp                      | 2 +-
 scripts/qmp/qmp-shell                | 2 +-
 scripts/qmp/qom-fuse                 | 2 +-
 scripts/render_block_graph.py        | 2 +-
 scripts/replay-dump.py               | 2 +-
 scripts/simpletrace.py               | 2 +-
 scripts/tracetool.py                 | 2 +-
 scripts/vmstate-static-checker.py    | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)
scripts/analyse-locks-simpletrace.py +1 -1
index 7d9b574300..9c263d6e79 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 #
 # Analyse lock events and compute statistics
scripts/decodetree.py +1 -1
index d8c59cab60..2a8f2b6e06 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (c) 2018 Linaro Limited
 #
 # This library is free software; you can redistribute it and/or
scripts/device-crash-test +1 -1
index 15f213a6cd..25ee968b66 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #  Copyright (c) 2017 Red Hat Inc
 #
scripts/kvm/kvm_flightrecorder +1 -1
index 54a56745e4..1391a84409 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # KVM Flight Recorder - ring buffer tracing script
 #
scripts/qapi-gen.py +1 -1
index f93f3c7c23..c7b0070db2 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # QAPI generator
 #
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
scripts/qmp/qemu-ga-client +1 -1
index 30cf8a9a0d..e4568aff68 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 # QEMU Guest Agent Client
 #
scripts/qmp/qmp +1 -1
index 6cb46fdae2..f85a14a627 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # QMP command line tool
 #
scripts/qmp/qmp-shell +1 -1
index f1cddeafbc..9e122ad0c6 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Low-level QEMU shell on top of QMP.
 #
scripts/qmp/qom-fuse +1 -1
index 4d85970a78..6bada2c33d 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 ##
 # QEMU Object Model test tools
 #
scripts/render_block_graph.py +1 -1
index 656f0388ad..409b4321f2 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Render Qemu Block Graph
 #
scripts/replay-dump.py +1 -1
index ee7fda2638..0cdae879b7 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 #
 # Dump the contents of a recorded execution stream
scripts/simpletrace.py +1 -1
index 45485b864b..2bc043112a 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Pretty-printer for simple trace backend binary trace files
 #
scripts/tracetool.py +1 -1
index 3beaa66bd8..264cc9eecc 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 """
scripts/vmstate-static-checker.py +1 -1
index f8b7b8f772..d44dedd9e9 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Compares vmstate information stored in JSON format, obtained from
 # the -dump-vmstate QEMU command.
Signature · 1 line
2.21.1
#6 lore raw

PATCH v2 6/12 scripts/minikconf: Explicit usage of Python 3

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created manually after running:

  $ git grep -l 'if __name__.*__main__' \
      | xargs grep -LF '#!/usr/bin/env python3'
---
 scripts/minikconf.py | 1 +
 1 file changed, 1 insertion(+)
scripts/minikconf.py +1 -0
index 40ae1989e1..377d6228b9 100644
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 #
 # Mini-Kconfig parser
 #
Signature · 1 line
2.21.1
#7 lore raw

PATCH v2 7/12 tests/acceptance: Remove shebang header

In reply to Philippe Mathieu-Daudé

Patch created mechanically by running:

  $ chmod 644 $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
  $ sed -i "/^#\!\/usr\/bin\/\(env\ \)\?python.\?$/d" \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
---
 tests/acceptance/virtio_seg_max_adjust.py  | 1 -
 tests/acceptance/x86_cpu_model_versions.py | 1 -
 2 files changed, 2 deletions(-)
 mode change 100755 => 100644 tests/acceptance/virtio_seg_max_adjust.py
tests/acceptance/virtio_seg_max_adjust.py +0 -1
old mode 100755
new mode 100644
index 5458573138..8d4f24da49
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Test virtio-scsi and virtio-blk queue settings for all machine types
 #
tests/acceptance/x86_cpu_model_versions.py +0 -1
index 90558d9a71..01ff614ec2 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Basic validation of x86 versioned CPU models and CPU model aliases
 #
Signature · 1 line
2.21.1
#8 lore raw

Re: [PATCH v2 07/12] tests/acceptance: Remove shebang header

Quoted 36 lines · Philippe Mathieu-Daudé

Patch created mechanically by running:

   $ chmod 644 $(git grep -lF '#!/usr/bin/env python' \
       | xargs grep -L 'if __name__.*__main__')
   $ sed -i "/^#\!\/usr\/bin\/\(env\ \)\?python.\?$/d" \
       $(git grep -lF '#!/usr/bin/env python' \
       | xargs grep -L 'if __name__.*__main__')
---
  tests/acceptance/virtio_seg_max_adjust.py  | 1 -
  tests/acceptance/x86_cpu_model_versions.py | 1 -
  2 files changed, 2 deletions(-)

mode change 100755 => 100644 tests/acceptance/virtio_seg_max_adjust.py

tests/acceptance/virtio_seg_max_adjust.py +0 -1
old mode 100755
new mode 100644
index 5458573138..8d4f24da49
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
  #
  # Test virtio-scsi and virtio-blk queue settings for all machine types
  #
tests/acceptance/x86_cpu_model_versions.py +0 -0
index 90558d9a71..01ff614ec2 100644

tests/acceptance/x86_cpu_model_versions.py line 3

Quoted 4 lines
tests/acceptance/x86_cpu_model_versions.py +0 -1
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
  #
  # Basic validation of x86 versioned CPU models and CPU model aliases
  #

Thanks, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next

#9 lore raw

Re: [PATCH v2 07/12] tests/acceptance: Remove shebang header

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Patch created mechanically by running:

  $ chmod 644 $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
  $ sed -i "/^#\!\/usr\/bin\/\(env\ \)\?python.\?$/d" \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')

OK, but my question is why? Aren't shebangs considered good practice for finding the executable for a script?

If the acceptance scripts are special in this regard we should say why in the commit message.

Quoted 32 lines
---
 tests/acceptance/virtio_seg_max_adjust.py  | 1 -
 tests/acceptance/x86_cpu_model_versions.py | 1 -
 2 files changed, 2 deletions(-)
 mode change 100755 => 100644 tests/acceptance/virtio_seg_max_adjust.py
tests/acceptance/virtio_seg_max_adjust.py +0 -1
old mode 100755
new mode 100644
index 5458573138..8d4f24da49
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Test virtio-scsi and virtio-blk queue settings for all machine types
 #
tests/acceptance/x86_cpu_model_versions.py +0 -1
index 90558d9a71..01ff614ec2 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Basic validation of x86 versioned CPU models and CPU model aliases
 #
Signature · 1 line
Alex Bennée
#10 lore raw

PATCH v2 8/12 scripts/tracetool: Remove shebang header

In reply to Philippe Mathieu-Daudé

Patch created mechanically by running:

  $ chmod 644 $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
  $ sed -i "/^#\!\/usr\/bin\/\(env\ \)\?python.\?$/d" \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
---
 scripts/tracetool/__init__.py                    | 1 -
 scripts/tracetool/backend/__init__.py            | 1 -
 scripts/tracetool/backend/dtrace.py              | 1 -
 scripts/tracetool/backend/ftrace.py              | 1 -
 scripts/tracetool/backend/log.py                 | 1 -
 scripts/tracetool/backend/simple.py              | 1 -
 scripts/tracetool/backend/syslog.py              | 1 -
 scripts/tracetool/backend/ust.py                 | 1 -
 scripts/tracetool/format/__init__.py             | 1 -
 scripts/tracetool/format/c.py                    | 1 -
 scripts/tracetool/format/d.py                    | 1 -
 scripts/tracetool/format/h.py                    | 1 -
 scripts/tracetool/format/log_stap.py             | 1 -
 scripts/tracetool/format/simpletrace_stap.py     | 1 -
 scripts/tracetool/format/stap.py                 | 1 -
 scripts/tracetool/format/tcg_h.py                | 1 -
 scripts/tracetool/format/tcg_helper_c.py         | 1 -
 scripts/tracetool/format/tcg_helper_h.py         | 1 -
 scripts/tracetool/format/tcg_helper_wrapper_h.py | 1 -
 scripts/tracetool/format/ust_events_c.py         | 1 -
 scripts/tracetool/format/ust_events_h.py         | 1 -
 scripts/tracetool/transform.py                   | 1 -
 scripts/tracetool/vcpu.py                        | 1 -
 23 files changed, 23 deletions(-)
scripts/tracetool/__init__.py +0 -1
index 44c118bc2a..13d29f1e42 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/__init__.py +0 -1
index 259c6a6531..54cab2c4de 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/dtrace.py +0 -1
index c2f3a4e5a8..638990db79 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/ftrace.py +0 -1
index 92f71b28f9..e9844dd335 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/log.py +0 -1
index 33c95af8e9..23b274c0fd 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/simple.py +0 -1
index c2fd1c24c4..b650c262b5 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/syslog.py +0 -1
index 668fb73fee..1373a90192 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/backend/ust.py +0 -1
index 280cb7c106..a772a3b53b 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/__init__.py +0 -1
index cf6e0e2da5..aba2f7a441 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/c.py +0 -1
index 31207961b0..78af8aff72 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/d.py +0 -1
index c7cb2a93a6..d3980b914b 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/h.py +0 -1
index 5596b304e6..83e1a2f355 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/log_stap.py +0 -1
index 9ab0cf2cce..b486beb672 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/simpletrace_stap.py +0 -1
index 57b04061cf..4f4633b4e6 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/stap.py +0 -1
index e8ef3e762d..8fc808f2ef 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/tcg_h.py +0 -1
index 1651cc3f71..0180e3d76c 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/tcg_helper_c.py +0 -1
index 1b3522a716..6527b69afd 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/tcg_helper_h.py +0 -1
index 6b184b641b..98ebe52f18 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/tcg_helper_wrapper_h.py +0 -1
index ff53447512..6adeab74df 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/ust_events_c.py +0 -1
index 264784cdf2..deced9533d 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/format/ust_events_h.py +0 -1
index b14054ac01..6ce559f6cc 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/transform.py +0 -1
index 2ca9286046..8fd4dcf20d 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
scripts/tracetool/vcpu.py +0 -1
index 452c7f589d..0b104e4f15 100644
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
Signature · 1 line
2.21.1
#11 lore raw

PATCH v2 9/12 tests/vm: Remove shebang header

In reply to Philippe Mathieu-Daudé

Patch created mechanically by running:

  $ chmod 644 $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
  $ sed -i "/^#\!\/usr\/bin\/\(env\ \)\?python.\?$/d" \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
---
 tests/vm/basevm.py | 1 -
 1 file changed, 1 deletion(-)
 mode change 100755 => 100644 tests/vm/basevm.py
tests/vm/basevm.py +0 -1
old mode 100755
new mode 100644
index ed5dd4f3d0..30714fa1a8
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # VM testing base class
 #
Signature · 1 line
2.21.1
#12 lore raw

PATCH v2 10/12 tests/qemu-iotests: Explicit usage of Python3 (scripts without __main__)

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created mechanically by running:

  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
---
 tests/qemu-iotests/149 | 2 +-
 tests/qemu-iotests/194 | 2 +-
 tests/qemu-iotests/202 | 2 +-
 tests/qemu-iotests/203 | 2 +-
 tests/qemu-iotests/206 | 2 +-
 tests/qemu-iotests/207 | 2 +-
 tests/qemu-iotests/208 | 2 +-
 tests/qemu-iotests/209 | 2 +-
 tests/qemu-iotests/210 | 2 +-
 tests/qemu-iotests/211 | 2 +-
 tests/qemu-iotests/212 | 2 +-
 tests/qemu-iotests/213 | 2 +-
 tests/qemu-iotests/216 | 2 +-
 tests/qemu-iotests/218 | 2 +-
 tests/qemu-iotests/219 | 2 +-
 tests/qemu-iotests/222 | 2 +-
 tests/qemu-iotests/224 | 2 +-
 tests/qemu-iotests/228 | 2 +-
 tests/qemu-iotests/234 | 2 +-
 tests/qemu-iotests/235 | 2 +-
 tests/qemu-iotests/236 | 2 +-
 tests/qemu-iotests/237 | 2 +-
 tests/qemu-iotests/238 | 2 +-
 tests/qemu-iotests/242 | 2 +-
 tests/qemu-iotests/246 | 2 +-
 tests/qemu-iotests/248 | 2 +-
 tests/qemu-iotests/254 | 2 +-
 tests/qemu-iotests/255 | 2 +-
 tests/qemu-iotests/256 | 2 +-
 tests/qemu-iotests/260 | 2 +-
 tests/qemu-iotests/262 | 2 +-
 tests/qemu-iotests/264 | 2 +-
 tests/qemu-iotests/266 | 2 +-
 tests/qemu-iotests/277 | 2 +-
 tests/qemu-iotests/280 | 2 +-
 35 files changed, 35 insertions(+), 35 deletions(-)
tests/qemu-iotests/149 +1 -1
index 8ab42e94c6..0a7b765d07 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2016 Red Hat, Inc.
 #
tests/qemu-iotests/194 +1 -1
index 72e47e8833..9dc1bd3510 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2017 Red Hat, Inc.
 #
tests/qemu-iotests/202 +1 -1
index 581ca34d79..920a8683ef 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2017 Red Hat, Inc.
 #
tests/qemu-iotests/203 +1 -1
index 4874a1a0d8..49eff5d405 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2017 Red Hat, Inc.
 #
tests/qemu-iotests/206 +1 -1
index 9f16a7df8d..e2b50ae24d 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test qcow2 and file image creation
 #
tests/qemu-iotests/207 +1 -1
index 812ab34e47..3d9c1208ca 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test ssh image creation
 #
tests/qemu-iotests/208 +1 -1
index 546eb1de3e..1c3fc8c7fd 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2018 Red Hat, Inc.
 #
tests/qemu-iotests/209 +1 -1
index e0f464bcbe..65c1a1e70a 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for NBD BLOCK_STATUS extension
 #
tests/qemu-iotests/210 +1 -1
index 4ca0fe26ef..e49896e23d 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test luks and file image creation
 #
tests/qemu-iotests/211 +1 -1
index 8834ebfe85..163994d559 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test VDI and file image creation
 #
tests/qemu-iotests/212 +1 -1
index 8f3ccc7b15..800f92dd84 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test parallels and file image creation
 #
tests/qemu-iotests/213 +1 -1
index 3fc8dc6eaa..1eee45276a 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test vhdx and file image creation
 #
tests/qemu-iotests/216 +1 -1
index 3c0ae54b44..372f042d3e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copy-on-read tests using a COR filter node
 #
tests/qemu-iotests/218 +1 -1
index 2554d84581..1325ba9eaa 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This test covers what happens when a mirror block job is cancelled
 # in various phases of its existence.
tests/qemu-iotests/219 +1 -1
index 655f54d881..b8774770c4 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2018 Red Hat, Inc.
 #
tests/qemu-iotests/222 +1 -1
index 3f9f934ad8..bf1718e179 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This test covers the basic fleecing workflow, which provides a
 # point-in-time snapshot of a node that can be queried over NBD.
tests/qemu-iotests/224 +1 -1
index b4dfaa639f..e91fb26fd8 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test json:{} filenames with qemu-internal BDSs
 # (the one of commit, to be precise)
tests/qemu-iotests/228 +1 -1
index 9a50afd205..64bc82ee23 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test for when a backing file is considered overridden (thus, a
 # json:{} filename is generated for the overlay) and when it is not
tests/qemu-iotests/234 +1 -1
index 59a7f949ec..324c1549fd 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2018 Red Hat, Inc.
 #
tests/qemu-iotests/235 +1 -1
index 3d7533980d..760826128e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Simple mirror test
 #
tests/qemu-iotests/236 +1 -1
index 79a6381f8e..8ce927a16c 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test bitmap merges.
 #
tests/qemu-iotests/237 +1 -1
index a2242a4736..50ba364a3e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test vmdk and file image creation
 #
tests/qemu-iotests/238 +1 -1
index e5ac2b2ff8..d4e060228c 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Regression test for throttle group member unregister segfault with iothread
 #
tests/qemu-iotests/242 +1 -1
index c176e92da6..97617876bc 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test for qcow2 bitmap printed information
 #
tests/qemu-iotests/246 +1 -1
index b0997a392f..59a216a839 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test persistent bitmap resizing.
 #
tests/qemu-iotests/248 +1 -1
index f26b4bb2aa..68c374692e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test resume mirror after auto pause on ENOSPC
 #
tests/qemu-iotests/254 +1 -1
index 09584f3f7d..ee66c986db 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test external snapshot with bitmap copying and moving.
 #
tests/qemu-iotests/255 +1 -1
index 0ba03d9e61..4a4818bafb 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test commit job graph modifications while requests are active
 #
tests/qemu-iotests/256 +1 -1
index c594a43205..e34074c83e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test incremental/backup across iothread contexts
 #
tests/qemu-iotests/260 +1 -1
index 4f6082c9d2..30c0de380d 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Tests for temporary external snapshot when we have bitmaps.
 #
tests/qemu-iotests/262 +1 -1
index bbcb5260a6..8835dce7be 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2019 Red Hat, Inc.
 #
tests/qemu-iotests/264 +1 -1
index 131366422b..879123a343 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test nbd reconnect
 #
tests/qemu-iotests/266 +1 -1
index c353cf88ee..91bdf8729e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test VPC and file image creation
 #
tests/qemu-iotests/277 +1 -1
index 1f72dca2d4..04aa15a3d5 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Test NBD client reconnection
 #
tests/qemu-iotests/280 +1 -1
index 85e9114c5e..69288fdd0e 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2019 Red Hat, Inc.
 #
Signature · 1 line
2.21.1
#13 lore raw

PATCH v2 11/12 scripts: Explicit usage of Python 3 (scripts without __main__)

In reply to Philippe Mathieu-Daudé

Use the program search path to find the Python 3 interpreter.

Patch created mechanically by running:

  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
---
 scripts/analyse-9p-simpletrace.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/analyse-9p-simpletrace.py +1 -1
index 710e01adba..f20050fddd 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Pretty print 9p simpletrace log
 # Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
 #
Signature · 1 line
2.21.1
#14 lore raw

PATCH v2 12/12 tests/qemu-iotests/check: Only check for Python 3 interpreter

In reply to Philippe Mathieu-Daudé

All the iotests Python scripts have been converted to search for the Python 3 interpreter. Update the ./check script accordingly.

---
 tests/qemu-iotests/check | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/qemu-iotests/check +1 -2
index bdcd64aea4..2e7d29d570 100755
@@ -825,8 +825,7 @@ do
 
         start=$(_wallclock)
 
-        if [ "$(head -n 1 "$source_iotests/$seq" | sed 's/3$//')" \
-            == "#!/usr/bin/env python" ]; then
+        if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python3" ]; then
             if $python_usable; then
                 run_command="$PYTHON $seq"
             else
Signature · 1 line
2.21.1
#16 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 26 lines · Philippe Mathieu-Daudé

Hello,

These are mechanical sed patches used to convert the code base to Python 3, as suggested on this thread:
https://www.mail-archive.com/[email protected]/msg675024.html

Since v1:
- new checkpatch.pl patch
- addressed Kevin and Vladimir review comments
- added R-b/A-b tags

Regards,

Phil.

Philippe Mathieu-Daudé (12):
scripts/checkpatch.pl: Only allow Python 3 interpreter tests/qemu-iotests/check: Allow use of python3 interpreter tests/qemu-iotests: Explicit usage of Python 3 (scripts with __main__)
tests: Explicit usage of Python 3
scripts: Explicit usage of Python 3 (scripts with __main__) scripts/minikconf: Explicit usage of Python 3 tests/acceptance: Remove shebang header
scripts/tracetool: Remove shebang header
tests/vm: Remove shebang header
tests/qemu-iotests: Explicit usage of Python3 (scripts without

Quoted 3 lines
     __main__)

scripts: Explicit usage of Python 3 (scripts without __main__) tests/qemu-iotests/check: Only check for Python 3 interpreter

Series applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next