Skip to content

Commit 6e1a7c5

Browse files
authored
Remove several mentions of Python 2 (#190)
* Remove several mentions of Python 2 Not all of them are removed with these changes, because I am not sure how best to remove some of them, e.g. in the file debian/control * Remove uses of six package
1 parent 9c1787d commit 6e1a7c5

7 files changed

Lines changed: 8 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ More information about Black, you find at
4141

4242
The following software is required to run PTF:
4343

44-
* Python 2.7 or 3.x
44+
* Python 3.x
4545
* six 1.16.0
4646
* Scapy 2.4.5 (unless you provide another packet manipulation module)
4747
* pypcap (optional - VLAN tests will fail without this)

ptf_nn/ptf_nn_agent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,7 @@ def forward(self, p, port):
305305
msg = struct.pack("<iii{}s".format(len(p)), self.MSG_TYPE_PACKET_OUT,
306306
port, len(p), p)
307307
# because nnpy expects unicode when using str
308-
if sys.version_info[0] == 2:
309-
msg = list(bytes(msg))
310-
else:
311-
msg = bytearray(msg)
308+
msg = bytearray(msg)
312309

313310
self.socket.send(msg)
314311

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
six==1.16.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package_dir=
1919
packages = find:
2020
scripts = ptf, ptf_nn/ptf_nn_agent.py
2121
platforms = any
22-
python_requires = >=2.7, >=3
22+
python_requires = >=3
2323
setup_requires =
2424
setuptools_scm
2525
install_requires = file: requirements.txt

src/ptf/dataplane.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from . import mask
3333
from . import packet
3434
from .pcap_writer import PcapWriter
35-
from six import StringIO
35+
from io import StringIO
3636

3737
try:
3838
import nnpy
@@ -321,10 +321,7 @@ def send(self, port_number, packet):
321321
packet,
322322
)
323323
# because nnpy expects unicode when using str
324-
if sys.version_info[0] == 2:
325-
msg = list(msg)
326-
else:
327-
msg = bytearray(msg)
324+
msg = bytearray(msg)
328325
self.socket.send(msg)
329326
# nnpy does not return the number of bytes sent
330327
return len(packet)

src/ptf/mask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import print_function
22
import warnings
33

4-
from six import StringIO
4+
from io import StringIO
55
import sys
66
from . import packet
77

src/ptf/testutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import ptf.parse
1212
import ptf.ptfutils
1313
import codecs
14-
from six import StringIO
14+
from io import StringIO
1515

1616
global skipped_test_count
1717
skipped_test_count = 0
@@ -3179,7 +3179,7 @@ def ptf_ports(num=None):
31793179

31803180

31813181
def port_to_tuple(port):
3182-
if type(port) is int or (sys.version_info[0] == 2 and type(port) is int):
3182+
if type(port) is int:
31833183
return 0, port
31843184
if type(port) is tuple:
31853185
return port

0 commit comments

Comments
 (0)