diff --git a/test/conftest.py b/test/conftest.py index 954195fdfb..f5b2f58be4 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # # Copyright (c) 2018 Peter Wu diff --git a/test/fixtures.py b/test/fixtures.py index 7961ce0abc..b31d452044 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Extends unittest with support for pytest-style fixtures. # # Copyright (c) 2018 Peter Wu diff --git a/test/fixtures_ws.py b/test/fixtures_ws.py index f03a41fac2..865647a39b 100644 --- a/test/fixtures_ws.py +++ b/test/fixtures_ws.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # # Copyright (c) 2018 Peter Wu diff --git a/test/matchers.py b/test/matchers.py index 5696d64e72..46005cac5a 100644 --- a/test/matchers.py +++ b/test/matchers.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # # Copyright (c) 2018 Peter Wu diff --git a/test/subprocesstest.py b/test/subprocesstest.py index 2d05974e32..87a382303a 100644 --- a/test/subprocesstest.py +++ b/test/subprocesstest.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_capture.py b/test/suite_capture.py index eb8c5f5c61..8b70136a78 100644 --- a/test/suite_capture.py +++ b/test/suite_capture.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_clopts.py b/test/suite_clopts.py index b488a0c084..8a25e2c4a0 100644 --- a/test/suite_clopts.py +++ b/test/suite_clopts.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_decryption.py b/test/suite_decryption.py index bab0641df9..bd2f6f68ee 100644 --- a/test/suite_decryption.py +++ b/test/suite_decryption.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_dfilter/group_string_type.py b/test/suite_dfilter/group_string_type.py index bf469d35c4..b6c4adfa0d 100644 --- a/test/suite_dfilter/group_string_type.py +++ b/test/suite_dfilter/group_string_type.py @@ -1,5 +1,5 @@ +# # Copyright (c) 2013 by Gilbert Ramirez -# -*- coding: utf-8 -*- # # SPDX-License-Identifier: GPL-2.0-or-later diff --git a/test/suite_dissection.py b/test/suite_dissection.py index d17fcc3496..6765f08527 100644 --- a/test/suite_dissection.py +++ b/test/suite_dissection.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_dissectors/dissectorstest.py b/test/suite_dissectors/dissectorstest.py index d2227ed9e1..58c526b331 100644 --- a/test/suite_dissectors/dissectorstest.py +++ b/test/suite_dissectors/dissectorstest.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Wireshark dissector tests # By Atli Guðmundsson diff --git a/test/suite_dissectors/group_asterix.py b/test/suite_dissectors/group_asterix.py index 068a8ed135..3943f30c46 100644 --- a/test/suite_dissectors/group_asterix.py +++ b/test/suite_dissectors/group_asterix.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Wireshark ASTERIX dissector tests # By Atli Guðmundsson diff --git a/test/suite_extcaps.py b/test/suite_extcaps.py index d086d92ef5..59132869ce 100644 --- a/test/suite_extcaps.py +++ b/test/suite_extcaps.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# # Wireshark tests # By Gerald Combs # diff --git a/test/suite_fileformats.py b/test/suite_fileformats.py index a2a9232803..a0cdf75a97 100644 --- a/test/suite_fileformats.py +++ b/test/suite_fileformats.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_follow.py b/test/suite_follow.py index 34c9b3cfec..5f0d81d605 100644 --- a/test/suite_follow.py +++ b/test/suite_follow.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # # Copyright (c) 2018 Peter Wu diff --git a/test/suite_io.py b/test/suite_io.py index be8fed715a..47725e422d 100644 --- a/test/suite_io.py +++ b/test/suite_io.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_mergecap.py b/test/suite_mergecap.py index 1c031c8150..f6f9265844 100644 --- a/test/suite_mergecap.py +++ b/test/suite_mergecap.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_nameres.py b/test/suite_nameres.py index 340639ae3c..bd4d5cd389 100644 --- a/test/suite_nameres.py +++ b/test/suite_nameres.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_outputformats.py b/test/suite_outputformats.py index bc5bf51e89..ab2a827002 100644 --- a/test/suite_outputformats.py +++ b/test/suite_outputformats.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# # Wireshark tests # By Gerald Combs # diff --git a/test/suite_release.py b/test/suite_release.py index 8775f1f982..d4cf2f921f 100644 --- a/test/suite_release.py +++ b/test/suite_release.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # # Copyright (c) 2019 Gerald Combs diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py index 612bcb4e61..0852d626f5 100644 --- a/test/suite_sharkd.py +++ b/test/suite_sharkd.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # @@ -459,4 +458,4 @@ class case_sharkd(subprocesstest.SubprocessTestCase): ), ( {"err": 0}, MatchAny(), - )) \ No newline at end of file + )) diff --git a/test/suite_text2pcap.py b/test/suite_text2pcap.py index 813d57403a..128ac79b82 100644 --- a/test/suite_text2pcap.py +++ b/test/suite_text2pcap.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/suite_unittests.py b/test/suite_unittests.py index 6200dcfcba..6081bb6596 100644 --- a/test/suite_unittests.py +++ b/test/suite_unittests.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By # Gerald Combs diff --git a/test/suite_wslua.py b/test/suite_wslua.py index a0a71ca790..e608954c6b 100644 --- a/test/suite_wslua.py +++ b/test/suite_wslua.py @@ -1,5 +1,4 @@ # -# -*- coding: utf-8 -*- # Wireshark tests # By Gerald Combs # diff --git a/test/test.py b/test/test.py index c1a3a6ee69..a21ab615a9 100755 --- a/test/test.py +++ b/test/test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Wireshark tests # By Gerald Combs @@ -38,10 +37,6 @@ def find_test_ids(suite, all_ids): all_ids.append(suite.id()) def main(): - if sys.version_info[0] < 3: - print("Unit tests require Python 3") - sys.exit(2) - parser = argparse.ArgumentParser(description='Wireshark unit tests') cap_group = parser.add_mutually_exclusive_group() cap_group.add_argument('-E', '--disable-capture', action='store_true', help='Disable capture tests') diff --git a/tools/checklicenses.py b/tools/checklicenses.py index ca98aab731..b339d3aea5 100755 --- a/tools/checklicenses.py +++ b/tools/checklicenses.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -186,9 +186,8 @@ def check_licenses(options, args): stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = licensecheck.communicate() - if sys.version_info[0] >= 3: - stdout = stdout.decode('utf-8') - stderr = stderr.decode('utf-8') + stdout = stdout.decode('utf-8') + stderr = stderr.decode('utf-8') if options.verbose: print('----------- licensecheck stdout -----------') print(stdout) diff --git a/tools/delete_includes.py b/tools/delete_includes.py index f8ed6a4370..45e27859b3 100755 --- a/tools/delete_includes.py +++ b/tools/delete_includes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Martin Mathieson # Look for and removes unnecessary includes in .cpp or .c files diff --git a/tools/generate-dissector.py b/tools/generate-dissector.py index 5a9b7818cb..f8b722488a 100755 --- a/tools/generate-dissector.py +++ b/tools/generate-dissector.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2019, Dario Lombardo # diff --git a/tools/generate-nl80211-fields.py b/tools/generate-nl80211-fields.py index 38358b9fa8..8e2b84d2b8 100755 --- a/tools/generate-nl80211-fields.py +++ b/tools/generate-nl80211-fields.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Parses the nl80211.h interface and generate appropriate enums and fields # (value_string) for packet-netlink-nl80211.c # diff --git a/tools/html2text.py b/tools/html2text.py index 829985b944..a2edbc268e 100755 --- a/tools/html2text.py +++ b/tools/html2text.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # # html2text.py - converts HTML to text # @@ -68,8 +67,7 @@ class TextHTMLParser(HTMLParser): 'initial_indent': initial_indent, 'subsequent_indent': indent } - if sys.version_info[0:2] >= (2, 6): - kwargs['break_on_hyphens'] = False + kwargs['break_on_hyphens'] = False wrapper = TextWrapper(**kwargs) return '\n'.join(wrapper.wrap(text)) diff --git a/tools/indexcap.py b/tools/indexcap.py index 01c04231b5..d18e76f6ee 100755 --- a/tools/indexcap.py +++ b/tools/indexcap.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Tool to index protocols that appears in the given capture files # @@ -29,8 +29,7 @@ def extract_protos_from_file_proces(tshark, file): cmd = [tshark, "-Tfields", "-e", "frame.protocols", "-r", file] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() - if sys.version_info[0] >= 3: - stdout = stdout.decode('utf-8') + stdout = stdout.decode('utf-8') if p.returncode != 0: return (file, {}) diff --git a/tools/json2pcap/json2pcap.py b/tools/json2pcap/json2pcap.py index 2acc7f659b..2a059ad021 100644 --- a/tools/json2pcap/json2pcap.py +++ b/tools/json2pcap/json2pcap.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # # Copyright 2020, Martin Kacer and contributors @@ -25,12 +24,6 @@ import re from collections import OrderedDict from scapy import all as scapy -try: - # Python 2 forward compatibility - range = xrange -except NameError: - pass - # Field anonymization class class AnonymizedField: ''' @@ -159,12 +152,6 @@ import subprocess from collections import OrderedDict from scapy import all as scapy -try: - # Python 2 forward compatibility - range = xrange -except NameError: - pass - # ***************************************************** # * PACKET PAYLOAD GENERATED FROM INPUT PCAP * # * Modify this function to edit the packet * diff --git a/tools/make-manuf.py b/tools/make-manuf.py index 8de37ebf3b..414d484849 100755 --- a/tools/make-manuf.py +++ b/tools/make-manuf.py @@ -179,10 +179,6 @@ def prefix_to_oui(prefix): return '{}/{:d}'.format(oui, int(pfx_len)) def main(): - if sys.version_info[0] < 3: - print("This requires Python 3") - sys.exit(2) - this_dir = os.path.dirname(__file__) template_path = os.path.join(this_dir, '..', 'manuf.tmpl') manuf_path = os.path.join(this_dir, '..', 'manuf') diff --git a/tools/make-no-reassembly-profile.py b/tools/make-no-reassembly-profile.py index 68786ab8b0..ccfbb45b61 100755 --- a/tools/make-no-reassembly-profile.py +++ b/tools/make-no-reassembly-profile.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # Generate preferences for a "No Reassembly" profile. # By Gerald Combs @@ -15,10 +14,6 @@ import subprocess import sys def main(): - if sys.version_info[0] < 3: - print("This requires Python 3") - sys.exit(2) - parser = argparse.ArgumentParser(description='No reassembly profile generator') parser.add_argument('-p', '--program-path', default=os.path.curdir, help='Path to TShark.') parser.add_argument('-v', '--verbose', action='store_const', const=True, default=False, help='Verbose output.') diff --git a/tools/make-plugin-reg.py b/tools/make-plugin-reg.py index 9e4819a683..946edb8d3b 100755 --- a/tools/make-plugin-reg.py +++ b/tools/make-plugin-reg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Looks for registration routines in the plugins # and assembles C code to call all the routines. diff --git a/tools/make-regs.py b/tools/make-regs.py index d8438b20f3..acc58fb314 100755 --- a/tools/make-regs.py +++ b/tools/make-regs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Looks for registration routines in the source files # and assembles C code to call all the routines. diff --git a/tools/make-usb.py b/tools/make-usb.py index 813ac7168d..9a8371aada 100755 --- a/tools/make-usb.py +++ b/tools/make-usb.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # make-usb - Creates a file containing vendor and product ids. # It use the databases from @@ -19,10 +18,6 @@ MIN_PRODUCTS = 15000 # 15415 as of 2015-06-28 mode = MODE_IDLE -if sys.version_info[0] < 3: - print("This requires Python 3") - sys.exit(2) - # Grab from linux-usb.org req_headers = { 'User-Agent': 'Wireshark make-usb' } req = urllib.request.Request('https://usb-ids.gowdy.us/usb.ids', headers=req_headers) diff --git a/tools/ncp2222.py b/tools/ncp2222.py index d55263a7ea..a09a9e7650 100755 --- a/tools/ncp2222.py +++ b/tools/ncp2222.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Creates C code from a table of NCP type 0x2222 packet types. diff --git a/tools/pre-commit-ignore.py b/tools/pre-commit-ignore.py index c0e1b63b2c..63ecf3e830 100755 --- a/tools/pre-commit-ignore.py +++ b/tools/pre-commit-ignore.py @@ -1,4 +1,4 @@ -#!/bin/env python +#!/bin/env python3 # # Wireshark - Network traffic analyzer # By Gerald Combs diff --git a/tools/rdps.py b/tools/rdps.py index 012563c8c7..64e62a1340 100755 --- a/tools/rdps.py +++ b/tools/rdps.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # rdps.py # diff --git a/tools/update-tools-help.py b/tools/update-tools-help.py index 625afacba8..e64391b986 100755 --- a/tools/update-tools-help.py +++ b/tools/update-tools-help.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # update-tools-help.py - Update the command line help output in docbook/wsug_src. # @@ -24,10 +23,6 @@ import subprocess import sys def main(): - if sys.version_info[0] < 3: - print("This requires Python 3") - sys.exit(2) - parser = argparse.ArgumentParser(description='Update Wireshark tools help') parser.add_argument('-p', '--program-path', nargs=1, default=os.path.curdir, help='Path to Wireshark executables.') args = parser.parse_args()