Skip to content

Commit 3795f93

Browse files
authored
Merge pull request #4738 from mwichmann/maint/py314
Final adjustments for Python 3.14
2 parents 7969f52 + 8c4e7c2 commit 3795f93

3 files changed

Lines changed: 22 additions & 33 deletions

File tree

CHANGES.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
7272
that can be rendered by Sphinx, and updating that text. The rest is
7373
minor fiddling like switching to f-strings small doc changes.
7474
- Fix a couple of unit tests to not fail with Python 3.14. These involve
75-
bytecode and error message contents, and there was no problem with
76-
SCons itself using 3.14 in its current (just-before-freeze) state.
75+
bytecode strings and error message contents; there was no problem with
76+
SCons itself using 3.14. Since 3.14 is now in Beta, there should
77+
be no further changes.
7778
- Replace use of old conditional expression idioms with the official
7879
one from PEP 308 introduced in Python 2.5 (2006). The idiom being
7980
replaced (using and/or) is regarded as error prone.

RELEASE.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ DEVELOPMENT
134134

135135
- Clean up C and C++ FLAGS tests. Tests which use a real compiler
136136
are now more clearly distinguished (-live.py suffix and docstring).
137+
137138
- Fix a couple of unit tests to not fail with Python 3.14. These involve
138-
expectations for bytecode and error message contents; there was no problem
139-
with SCons itself using 3.14 in its current (just-before-freeze) state.
139+
expectations for bytecode strings and error message contents; there was
140+
no problem with SCons itself using 3.14.
140141

141142
Thanks to the following contributors listed below for their contributions to this release.
142143
==========================================================================================

SCons/ActionTests.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def __call__(self) -> None:
4747
from subprocess import PIPE
4848
from typing import TYPE_CHECKING
4949

50+
# If assertEqual truncates strings so it's hard to see the diff, enable this:
51+
# if 'unittest.util' in __import__('sys').modules:
52+
# __import__('sys').modules['unittest.util']._MAX_LENGTH = 99999999
53+
5054
import SCons.Action
5155
import SCons.Environment
5256
import SCons.Errors
@@ -1552,7 +1556,7 @@ def LocalFunc() -> None:
15521556
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
15531557
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
15541558
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1555-
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
1559+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00R\x00#\x00),(),()'),
15561560
}
15571561

15581562
meth_matches = [
@@ -1733,7 +1737,7 @@ def LocalFunc() -> None:
17331737
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
17341738
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
17351739
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1736-
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
1740+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00R\x00#\x00),(),()'),
17371741

17381742
}
17391743

@@ -1745,7 +1749,7 @@ def LocalFunc() -> None:
17451749
(3, 11): bytearray(b'1, 1, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
17461750
(3, 12): bytearray(b'1, 1, 0, 0,(),(),(\x97\x00y\x00),(),()'),
17471751
(3, 13): bytearray(b'1, 1, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1748-
(3, 14): bytearray(b'1, 1, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
1752+
(3, 14): bytearray(b'1, 1, 0, 0,(),(),(\x80\x00R\x00#\x00),(),()'),
17491753
}
17501754

17511755
def factory(act, **kw):
@@ -1986,7 +1990,7 @@ def LocalFunc() -> None:
19861990
(3, 11): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00d\x00S\x00),(),()'),
19871991
(3, 12): bytearray(b'0, 0, 0, 0,(),(),(\x97\x00y\x00),(),()'),
19881992
(3, 13): bytearray(b'0, 0, 0, 0,(),(),(\x95\x00g\x00),(),()'),
1989-
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00P\x00"\x00),(),()'),
1993+
(3, 14): bytearray(b'0, 0, 0, 0,(),(),(\x80\x00R\x00#\x00),(),()'),
19901994
}
19911995

19921996
meth_matches = [
@@ -2049,7 +2053,7 @@ def LocalFunc() -> None:
20492053
(3, 11): b'\x97\x00d\x00S\x00',
20502054
(3, 12): b'\x97\x00y\x00',
20512055
(3, 13): b'\x95\x00g\x00',
2052-
(3, 14): b'\x80\x00P\x00"\x00',
2056+
(3, 14): b'\x80\x00R\x00#\x00',
20532057
}
20542058

20552059
with self.subTest():
@@ -2255,14 +2259,7 @@ def func1(a, b, c):
22552259
(3, 11): (bytearray(b"3, 3, 0, 0,(),(),(\x97\x00|\x00S\x00),(),()"),),
22562260
(3, 12): (bytearray(b"3, 3, 0, 0,(),(),(\x97\x00|\x00S\x00),(),()"),),
22572261
(3, 13): (bytearray(b"3, 3, 0, 0,(),(),(\x95\x00U\x00$\x00),(),()"),),
2258-
(3, 14): (
2259-
bytearray(
2260-
b'3, 3, 0, 0,(),(),(\x80\x00T\x00"\x00),(),()'
2261-
), # win32 has different bytecodes
2262-
bytearray(
2263-
b'3, 3, 0, 0,(),(),(\x80\x00R\x00"\x00),(),()'
2264-
), # every other OS?
2265-
),
2262+
(3, 14): (bytearray(b"3, 3, 0, 0,(),(),(\x80\x00V\x00#\x00),(),()"),),
22662263
}
22672264

22682265
c = SCons.Action._function_contents(func1)
@@ -2301,16 +2298,11 @@ def test_object_contents(self) -> None:
23012298
(3, 13): bytearray(
23022299
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}}}"
23032300
),
2304-
(3, 14): (
2305-
bytearray(
2306-
b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80\x00P\x00T\x00l\x00\x00\x00\x00\x00\x00\x00\x00\x00P\x01T\x00l\x01\x00\x00\x00\x00\x00\x00\x00\x00P\x02\"\x00),(),(),2, 2, 0, 0,(),(),(\x80\x00P\x00\"\x00),(),()}}{{{a=a,b=b}}}"
2307-
), # win32
2308-
bytearray(
2309-
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}}}"
2310-
),
2301+
(3, 14): bytearray(
2302+
b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80\x00R\x00V\x00n\x00\x00\x00\x00\x00\x00\x00\x00\x00R\x01V\x00n\x01\x00\x00\x00\x00\x00\x00\x00\x00R\x02#\x00),(),(),2, 2, 0, 0,(),(),(\x80\x00R\x00#\x00),(),()}}{{{a=a,b=b}}}"
23112303
),
23122304
}
2313-
self.assertTrue(c in expected[sys.version_info[:2]])
2305+
self.assertEqual(c, expected[sys.version_info[:2]])
23142306

23152307
def test_code_contents(self) -> None:
23162308
"""Test that Action._code_contents works"""
@@ -2341,17 +2333,12 @@ def test_code_contents(self) -> None:
23412333
(3, 13): bytearray(
23422334
b'0, 0, 0, 0,(Hello, World!),(print),(\x95\x00\\\x00"\x00S\x005\x01\x00\x00\x00\x00\x00\x00 \x00g\x01)'
23432335
),
2344-
(3, 14): (
2345-
bytearray(
2346-
b'0, 0, 0, 0,(Hello, World!),(print),(\x80\x00[\x00 \x00P\x002\x01\x00\x00\x00\x00\x00\x00\x1e\x00P\x01"\x00)'
2347-
), # win32
2348-
bytearray(
2349-
b'0, 0, 0, 0,(Hello, World!),(print),(\x80\x00Y\x00 \x00P\x002\x01\x00\x00\x00\x00\x00\x00\x1e\x00P\x01"\x00)'
2350-
),
2336+
(3, 14): bytearray(
2337+
b"0, 0, 0, 0,(Hello, World!),(print),(\x80\x00]\x00!\x00R\x004\x01\x00\x00\x00\x00\x00\x00\x1f\x00R\x01#\x00)"
23512338
),
23522339
}
23532340

2354-
self.assertTrue(c in expected[sys.version_info[:2]],f"\nExpected:{expected[sys.version_info[:2]]}\nGot :{c}")
2341+
self.assertEqual(c, expected[sys.version_info[:2]])
23552342

23562343
def test_uncaught_exception_bubbles(self):
23572344
"""Test that scons_subproc_run bubbles uncaught exceptions"""

0 commit comments

Comments
 (0)