Skip to content

Commit 514d162

Browse files
veluca93wil93
andcommitted
Remove python2.
It is not supported on the latest Ubuntu LTS, and has been unsupported for almost 5 years. Co-Authored-By: William Di Luigi <[email protected]>
1 parent fd93545 commit 514d162

File tree

17 files changed

+56
-147
lines changed

17 files changed

+56
-147
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
1717
openjdk-8-jdk-headless \
1818
php7.4-cli \
1919
postgresql-client \
20-
python2 \
2120
python3-pip \
2221
python3.8 \
2322
python3.8-dev \

cms/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __init__(self):
167167
# the prefix (or real_prefix to accommodate virtualenvs).
168168
bin_path = os.path.join(os.getcwd(), sys.argv[0])
169169
bin_name = os.path.basename(bin_path)
170-
bin_is_python = bin_name in ["ipython", "python", "python2", "python3"]
170+
bin_is_python = bin_name in ["ipython", "python", "python3"]
171171
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
172172
hasattr(sys, 'real_prefix')
173173
and bin_path.startswith(sys.real_prefix))

cms/grading/languages/python2_cpython.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

cmsranking/Config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self):
6161
# TODO: move to cmscommon as it is used both here and in cms/conf.py
6262
bin_path = os.path.join(os.getcwd(), sys.argv[0])
6363
bin_name = os.path.basename(bin_path)
64-
bin_is_python = bin_name in ["ipython", "python", "python2", "python3"]
64+
bin_is_python = bin_name in ["ipython", "python", "python3"]
6565
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
6666
hasattr(sys, 'real_prefix')
6767
and bin_path.startswith(sys.real_prefix))

cmstestsuite/Tests.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,19 @@
4848
LANG_JAVA = "Java / JDK"
4949
LANG_PASCAL = "Pascal / fpc"
5050
LANG_PHP = "PHP"
51-
LANG_PYTHON = "Python 2 / CPython"
5251
LANG_PYTHON3 = "Python 3 / CPython"
5352
LANG_RUST = "Rust"
5453
LANG_C_SHARP = "C# / Mono"
5554
ALL_LANGUAGES = (
5655
LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_C, LANG_HS, LANG_JAVA, LANG_PASCAL,
57-
LANG_PHP, LANG_PYTHON, LANG_PYTHON3, LANG_RUST, LANG_C_SHARP
56+
LANG_PHP, LANG_PYTHON3, LANG_RUST, LANG_C_SHARP
5857
)
5958
NON_INTERPRETED_LANGUAGES = (
6059
LANG_C, LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_PASCAL
6160
)
6261
COMPILED_LANGUAGES = (
6362
LANG_C, LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_PASCAL, LANG_JAVA,
64-
LANG_PYTHON, LANG_PYTHON3, LANG_HS, LANG_RUST, LANG_C_SHARP
63+
LANG_PYTHON3, LANG_HS, LANG_RUST, LANG_C_SHARP
6564
)
6665

6766
ALL_TESTS = [

cmstestsuite/tasks/batch_fileio_managed/code/checker

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/python2 -sS
1+
#!/usr/bin/python3 -sS
22

3-
from __future__ import print_function
43

54
import io
65
import sys
@@ -17,11 +16,11 @@ try:
1716
f = io.open(output_file, 'rb')
1817
line = f.readline().strip()
1918
more = f.readline()
20-
if line == '%s %d' % (solution_word, number) and more == '':
19+
if line == b'%s %d' % (solution_word, number) and more == b'':
2120
print("1.0")
2221
print("Correcto", file=sys.stderr)
2322
else:
24-
assert more == ''
23+
assert more == b''
2524
print("0.0")
2625
print("Plain wrong", file=sys.stderr)
2726
except:

cmstestsuite/tasks/communication_fifoio_stubbed/code/manager

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/python2 -sS
1+
#!/usr/bin/python3 -sS
22

3-
from __future__ import print_function
43

54
import io
65
import sys
@@ -17,28 +16,28 @@ correct = True
1716

1817
# Speak the to program a few times, check what it does, and output the last
1918
# line.
20-
for i in range(10,20) + [0]:
19+
for i in list(range(10, 20)) + [0]:
2120
x = i + input_value
2221
# Write a question to the candidate executable.
23-
fifo_to_user.write("%d\n" % x)
22+
fifo_to_user.write(b"%d\n" % x)
2423
# Read their response.
2524
l = fifo_from_user.readline()
2625
# EOF?
27-
if l == '':
26+
if l == b'':
2827
correct = False
2928
break
3029
# These are the only things we expect from our stub.
31-
if l.strip() != 'correct %d' % x:
30+
if l.strip() != b'correct %d' % x:
3231
correct = False
3332
break
3433

3534
correct = correct and (int(l.split()[1]) == x)
3635
else:
3736
# Tell stub to exit.
38-
fifo_to_user.write("0\n")
37+
fifo_to_user.write(b"0\n")
3938

4039
# This file exists just for convenience.
41-
io.open("output.txt", "wb").write(l + "\n")
40+
io.open("output.txt", "wb").write(l + b"\n")
4241

4342
# This is the final score.
4443
if correct:

cmstestsuite/tasks/communication_many_fifoio_stubbed/code/manager

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/python2 -sS
1+
#!/usr/bin/python3 -sS
22

3-
from __future__ import print_function
43

54
import io
65
import sys
@@ -20,44 +19,44 @@ correct = True
2019

2120
# Speak the to program a few times, check what it does, and output the last
2221
# line.
23-
for i in range(10, 20) + [0]:
22+
for i in list(range(10, 20)) + [0]:
2423
x = i + input_value
2524
# Write a question to the candidate executable.
26-
fifo_to_user1.write("%d\n" % x)
25+
fifo_to_user1.write(b"%d\n" % x)
2726
# Read their response.
2827
l = fifo_from_user1.readline()
2928
# EOF?
30-
if l == '':
29+
if l == b'':
3130
correct = False
3231
break
3332
# These are the only things we expect from our stub.
34-
if l.strip() != 'correct %d' % x:
33+
if l.strip() != b'correct %d' % x:
3534
correct = False
3635
break
3736

3837
correct = correct and (int(l.split()[1]) == x)
3938

4039
# Write a question to the candidate executable.
41-
fifo_to_user2.write("%d\n" % x)
40+
fifo_to_user2.write(b"%d\n" % x)
4241
# Read their response.
4342
l = fifo_from_user2.readline()
4443
# EOF?
45-
if l == '':
44+
if l == b'':
4645
correct = False
4746
break
4847
# These are the only things we expect from our stub.
49-
if l.strip() != 'correct %d' % (-x):
48+
if l.strip() != b'correct %d' % (-x):
5049
correct = False
5150
break
5251

5352
correct = correct and (int(l.split()[1]) == -x)
5453
else:
5554
# Tell stub to exit.
56-
fifo_to_user1.write("0\n")
57-
fifo_to_user2.write("0\n")
55+
fifo_to_user1.write(b"0\n")
56+
fifo_to_user2.write(b"0\n")
5857

5958
# This file exists just for convenience.
60-
io.open("output.txt", "wb").write(l + "\n")
59+
io.open("output.txt", "wb").write(l + b"\n")
6160

6261
# This is the final score.
6362
if correct:

cmstestsuite/tasks/communication_many_stdio_stubbed/code/manager

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/python2 -sS
1+
#!/usr/bin/python3 -sS
22

3-
from __future__ import print_function
43

54
import io
65
import sys
@@ -22,44 +21,44 @@ correct = True
2221

2322
# Speak the to program a few times, check what it does, and output the last
2423
# line.
25-
for i in range(10, 20) + [0]:
24+
for i in list(range(10, 20)) + [0]:
2625
x = i + input_value
2726
# Write a question to the candidate executable.
28-
fifo_to_user1.write("%d\n" % x)
27+
fifo_to_user1.write(b"%d\n" % x)
2928
# Read their response.
3029
l = fifo_from_user1.readline()
3130
# EOF?
32-
if l == '':
31+
if l == b'':
3332
correct = False
3433
break
3534
# These are the only things we expect from our stub.
36-
if l.strip() != 'correct %d' % x:
35+
if l.strip() != b'correct %d' % x:
3736
correct = False
3837
break
3938

4039
correct = correct and (int(l.split()[1]) == x)
4140

4241
# Write a question to the candidate executable.
43-
fifo_to_user2.write("%d\n" % x)
42+
fifo_to_user2.write(b"%d\n" % x)
4443
# Read their response.
4544
l = fifo_from_user2.readline()
4645
# EOF?
47-
if l == '':
46+
if l == b'':
4847
correct = False
4948
break
5049
# These are the only things we expect from our stub.
51-
if l.strip() != 'correct %d' % (-x):
50+
if l.strip() != b'correct %d' % (-x):
5251
correct = False
5352
break
5453

5554
correct = correct and (int(l.split()[1]) == -x)
5655
else:
5756
# Tell stub to exit.
58-
fifo_to_user1.write("0\n")
59-
fifo_to_user2.write("0\n")
57+
fifo_to_user1.write(b"0\n")
58+
fifo_to_user2.write(b"0\n")
6059

6160
# This file exists just for convenience.
62-
io.open("output.txt", "wb").write(l + "\n")
61+
io.open("output.txt", "wb").write(l + b"\n")
6362

6463
# This is the final score.
6564
if correct:

cmstestsuite/tasks/communication_stdio/code/manager

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/python2 -sS
1+
#!/usr/bin/python3 -sS
22

3-
from __future__ import print_function
43

54
import io
65
import sys
@@ -19,28 +18,28 @@ correct = True
1918

2019
# Speak the to program a few times, check what it does, and output the last
2120
# line.
22-
for i in range(10,20) + [0]:
21+
for i in list(range(10, 20)) + [0]:
2322
x = i + input_value
2423
# Write a question to the candidate executable.
25-
fifo_to_user.write("%d\n" % x)
24+
fifo_to_user.write(b"%d\n" % x)
2625
# Read their response.
2726
l = fifo_from_user.readline()
2827
# EOF?
29-
if l == '':
28+
if l == b'':
3029
correct = False
3130
break
3231
# These are the only things we expect from our stub.
33-
if l.strip() != 'correct %d' % x:
32+
if l.strip() != b'correct %d' % x:
3433
correct = False
3534
break
3635

3736
correct = correct and (int(l.split()[1]) == x)
3837
else:
3938
# Tell stub to exit.
40-
fifo_to_user.write("0\n")
39+
fifo_to_user.write(b"0\n")
4140

4241
# This file exists just for convenience.
43-
io.open("output.txt", "wb").write(l + "\n")
42+
io.open("output.txt", "wb").write(l + b"\n")
4443

4544
# This is the final score.
4645
if correct:

0 commit comments

Comments
 (0)