Skip to content

Commit 122b1b5

Browse files
authored
Merge pull request SCons#4712 from mwichmann/py314
Fix tests for use with Python 3.14
2 parents 0d888fc + e0c8655 commit 122b1b5

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2727
- runtest.py once again finds "external" tests, such as the tests for
2828
tools in scons-contrib. An earlier rework had broken this. Fixes #4699.
2929
- Clarify how pre/post actions on an alias work.
30+
- Fix a couple of unit tests to not fail with Python 3.14. These involve
31+
bytecode and error message contents, and there was no problem with
32+
SCons itself using 3.14 in its current (just-before-freeze) state.
3033
- Replace use of old conditional expression idioms with the official
3134
one from PEP 308 introduced in Python 2.5 (2006). The idiom being
3235
replaced (using and/or) is regarded as error prone.

RELEASE.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ DEVELOPMENT
6868
- runtest.py once again finds "external" tests, such as the tests for
6969
tools in scons-contrib. An earlier rework had broken this. Fixes #4699.
7070

71+
- Fix a couple of unit tests to not fail with Python 3.14. These involve
72+
expectations for bytecode and error message contents; there was no problem
73+
with SCons itself using 3.14 in its current (just-before-freeze) state.
74+
7175
Thanks to the following contributors listed below for their contributions to this release.
7276
==========================================================================================
7377
.. code-block:: text

SCons/ActionTests.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ def LocalFunc() -> None:
15521552
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
15531553
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
15541554
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1555+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
15551556
}
15561557

15571558
meth_matches = [
@@ -1732,6 +1733,7 @@ def LocalFunc() -> None:
17321733
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
17331734
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
17341735
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1736+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
17351737

17361738
}
17371739

@@ -1743,6 +1745,7 @@ def LocalFunc() -> None:
17431745
(3, 11): bytearray(b'1, 1, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
17441746
(3, 12): bytearray(b'1, 1, 0, 0,(),(),(\x97\x00y\x00),(),()'),
17451747
(3, 13): bytearray(b'1, 1, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1748+
(3, 14): bytearray(b'1, 1, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
17461749
}
17471750

17481751
def factory(act, **kw):
@@ -1983,6 +1986,7 @@ def LocalFunc() -> None:
19831986
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
19841987
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
19851988
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1989+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
19861990
}
19871991

19881992
meth_matches = [
@@ -2045,6 +2049,7 @@ def LocalFunc() -> None:
20452049
(3, 11): b'\x97\x00d\x00S\x00',
20462050
(3, 12): b'\x97\x00y\x00',
20472051
(3, 13): b'\x95\x00g\x00',
2052+
(3, 14): b'\x80\x00P\x00"\x00',
20482053
}
20492054

20502055
with self.subTest():
@@ -2250,6 +2255,7 @@ def func1(a, b, c):
22502255
(3, 11): (bytearray(b'3, 3, 0, 0,(),(),(\x97\x00|\x00S\x00),(),()'),),
22512256
(3, 12): (bytearray(b'3, 3, 0, 0,(),(),(\x97\x00|\x00S\x00),(),()'),),
22522257
(3, 13): (bytearray(b'3, 3, 0, 0,(),(),(\x95\x00U\x00$\x00),(),()'),),
2258+
(3, 14): (bytearray(b'3, 3, 0, 0,(),(),(\x80\x00R\x00"\x00),(),()'),),
22532259
}
22542260

22552261
c = SCons.Action._function_contents(func1)
@@ -2288,9 +2294,13 @@ def test_object_contents(self) -> None:
22882294
(3, 13): bytearray(
22892295
b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x95\x00S\x01U\x00l\x00\x00\x00\x00\x00\x00\x00\x00\x00S\x02U\x00l\x01\x00\x00\x00\x00\x00\x00\x00\x00g\x00),(),(),2, 2, 0, 0,(),(),(\x95\x00g\x00),(),()}}{{{a=a,b=b}}}"
22902296
),
2297+
(3, 14): bytearray(
2298+
b'{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80\x00P\x00R\x00j\x00\x00\x00\x00\x00\x00\x00\x00\x00P\x01R\x00j\x01\x00\x00\x00\x00\x00\x00\x00\x00P\x02"\x00),(),(),2, 2, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()}}{{{a=a,b=b}}}'
2299+
),
22912300
}
22922301

2293-
self.assertEqual(c, expected[sys.version_info[:2]])
2302+
# self.assertEqual(c, expected[sys.version_info[:2]])
2303+
assert c == expected[sys.version_info[:2]], c
22942304

22952305
def test_code_contents(self) -> None:
22962306
"""Test that Action._code_contents works"""
@@ -2321,6 +2331,9 @@ def test_code_contents(self) -> None:
23212331
(3, 13): bytearray(
23222332
b'0, 0, 0, 0,(Hello, World!),(print),(\x95\x00\\\x00"\x00S\x005\x01\x00\x00\x00\x00\x00\x00 \x00g\x01)'
23232333
),
2334+
(3, 14): bytearray(
2335+
b'0, 0, 0, 0,(Hello, World!),(print),(\x80\x00Y\x00 \x00P\x002\x01\x00\x00\x00\x00\x00\x00\x1e\x00P\x01"\x00)'
2336+
),
23242337
}
23252338

23262339
self.assertEqual(c, expected[sys.version_info[:2]])

SCons/Taskmaster/TaskmasterTests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ def test_exception(self) -> None:
11611161
"integer division or modulo",
11621162
"integer division or modulo by zero",
11631163
"integer division by zero", # PyPy2
1164+
"division by zero", # Python 3.14+
11641165
]
11651166
assert str(exc_value) in exception_values, exc_value
11661167

0 commit comments

Comments
 (0)