Skip to content

Commit db40145

Browse files
committed
Merge branch 'master' into jbrill-msvc-detect
Manually resolve conflicts: * RELEASE.txt
2 parents d0ced8a + 04c5b6e commit db40145

16 files changed

+230
-153
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
118118
old Python 2-only code block in a test.
119119
- scons-time tests now supply a "filter" argument to tarfile.extract
120120
to quiet a warning which was added in Python 3.13 beta 1.
121+
- Improved the conversion of a "foreign" exception from an action
122+
into BuildError by making sure our defaults get applied even in
123+
corner cases. Fixes #4530.
124+
- Restructured API docs build (Sphinx) so main module contents appear
125+
on a given page *before* the submodule docs, not after. Also
126+
tweaked the Util package doc build so it's structured more like the
127+
other packages (a missed part of the transition when it was split).
121128

122129

123130
RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700

RELEASE.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ FIXES
5858
-----
5959

6060
- OSErrors are now no longer hidden during the execution of Actions.
61+
- Improved the conversion of a "foreign" exception from an action
62+
into BuildError by making sure our defaults get applied even in
63+
corner cases. Fixes Issue #4530
6164
- MSVC: Visual Studio 2010 (10.0) could be inadvertently detected due to an
6265
sdk-only install of Windows SDK 7.1. An sdk-only install of Visual Studio
6366
2010 is ignored as the msvc batch files will fail. The installed files are
@@ -118,6 +121,8 @@ DOCUMENTATION
118121
- Updated Value Node docs.
119122
- Update manpage for Tools, and for the TOOL variable.
120123
- Update manpage and user guide for Variables usage.
124+
- Restructured API Docs build so main package contents are listed
125+
before contents of package submodules.
121126

122127

123128

SCons/Debug.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
"""Code for debugging SCons internal things.
2525
26-
Shouldn't be needed by most users. Quick shortcuts:
26+
Shouldn't be needed by most users. Quick shortcuts::
2727
28-
from SCons.Debug import caller_trace
29-
caller_trace()
28+
from SCons.Debug import caller_trace
29+
caller_trace()
3030
"""
3131

3232
import atexit

SCons/Errors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ def convert_to_BuildError(status, exc_info=None):
177177
# (for example, failure to create the directory in which the
178178
# target file will appear).
179179
filename = getattr(status, 'filename', None)
180-
strerror = getattr(status, 'strerror', str(status))
181-
errno = getattr(status, 'errno', 2)
180+
strerror = getattr(status, 'strerror', None)
181+
if strerror is None:
182+
strerror = str(status)
183+
errno = getattr(status, 'errno', None)
184+
if errno is None:
185+
errno = 2
182186

183187
buildError = BuildError(
184188
errstr=strerror,

SCons/ErrorsTests.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_BuildError(self):
4646
assert e.command == "c"
4747

4848
try:
49-
raise SCons.Errors.BuildError("n", "foo", 57, 3, "file",
49+
raise SCons.Errors.BuildError("n", "foo", 57, 3, "file",
5050
"e", "a", "c", (1,2,3))
5151
except SCons.Errors.BuildError as e:
5252
assert e.errstr == "foo", e.errstr
@@ -96,26 +96,48 @@ def test_ExplicitExit(self):
9696
assert e.node == "node"
9797

9898
def test_convert_EnvironmentError_to_BuildError(self) -> None:
99-
"""Test the convert_to_BuildError function on SConsEnvironmentError
100-
exceptions.
101-
"""
99+
"""Test convert_to_BuildError on SConsEnvironmentError."""
102100
ee = SCons.Errors.SConsEnvironmentError("test env error")
103101
be = SCons.Errors.convert_to_BuildError(ee)
104-
assert be.errstr == "test env error"
105-
assert be.status == 2
106-
assert be.exitstatus == 2
107-
assert be.filename is None
102+
with self.subTest():
103+
self.assertEqual(be.errstr, "test env error")
104+
with self.subTest():
105+
self.assertEqual(be.status, 2)
106+
with self.subTest():
107+
self.assertEqual(be.exitstatus, 2)
108+
with self.subTest():
109+
self.assertIsNone(be.filename)
108110

109111
def test_convert_OSError_to_BuildError(self) -> None:
110-
"""Test the convert_to_BuildError function on OSError
111-
exceptions.
112-
"""
112+
"""Test convert_to_BuildError on OSError."""
113113
ose = OSError(7, 'test oserror')
114114
be = SCons.Errors.convert_to_BuildError(ose)
115-
assert be.errstr == 'test oserror'
116-
assert be.status == 7
117-
assert be.exitstatus == 2
118-
assert be.filename is None
115+
with self.subTest():
116+
self.assertEqual(be.errstr, 'test oserror')
117+
with self.subTest():
118+
self.assertEqual(be.status, 7)
119+
with self.subTest():
120+
self.assertEqual(be.exitstatus, 2)
121+
with self.subTest():
122+
self.assertIsNone(be.filename)
123+
124+
def test_convert_phony_OSError_to_BuildError(self) -> None:
125+
"""Test convert_to_BuildError on OSError with defaults."""
126+
class PhonyException(OSError):
127+
def __init__(self, name):
128+
OSError.__init__(self, name) # most fields will default to None
129+
self.name = name
130+
131+
ose = PhonyException("test oserror")
132+
be = SCons.Errors.convert_to_BuildError(ose)
133+
with self.subTest():
134+
self.assertEqual(be.errstr, 'test oserror')
135+
with self.subTest():
136+
self.assertEqual(be.status, 2)
137+
with self.subTest():
138+
self.assertEqual(be.exitstatus, 2)
139+
with self.subTest():
140+
self.assertIsNone(be.filename)
119141

120142

121143
if __name__ == "__main__":

SCons/PathList.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
"""Handle lists of directory paths.
2525
26-
These are the path lists that get set as CPPPATH, LIBPATH,
26+
These are the path lists that get set as ``CPPPATH``, ``LIBPATH``,
2727
etc.) with as much caching of data and efficiency as we can, while
2828
still keeping the evaluation delayed so that we Do the Right Thing
2929
(almost) regardless of how the variable is specified.
@@ -47,10 +47,10 @@ def node_conv(obj):
4747
"""
4848
This is the "string conversion" routine that we have our substitutions
4949
use to return Nodes, not strings. This relies on the fact that an
50-
EntryProxy object has a get() method that returns the underlying
51-
Node that it wraps, which is a bit of architectural dependence
52-
that we might need to break or modify in the future in response to
53-
additional requirements.
50+
:class:`~SCons.Node.FS.EntryProxy` object has a ``get()`` method that
51+
returns the underlying Node that it wraps, which is a bit of
52+
architectural dependence that we might need to break or modify in the
53+
future in response to additional requirements.
5454
"""
5555
try:
5656
get = obj.get
@@ -64,34 +64,35 @@ def node_conv(obj):
6464
return result
6565

6666
class _PathList:
67-
"""An actual PathList object."""
67+
"""An actual PathList object.
6868
69-
def __init__(self, pathlist, split=True) -> None:
70-
"""
71-
Initializes a PathList object, canonicalizing the input and
72-
pre-processing it for quicker substitution later.
69+
Initializes a :class:`PathList` object, canonicalizing the input and
70+
pre-processing it for quicker substitution later.
7371
74-
The stored representation of the PathList is a list of tuples
75-
containing (type, value), where the "type" is one of the TYPE_*
76-
variables defined above. We distinguish between:
72+
The stored representation of the :class:`PathList` is a list of tuples
73+
containing (type, value), where the "type" is one of the ``TYPE_*``
74+
variables defined above. We distinguish between:
7775
78-
strings that contain no '$' and therefore need no
79-
delayed-evaluation string substitution (we expect that there
80-
will be many of these and that we therefore get a pretty
81-
big win from avoiding string substitution)
76+
* Strings that contain no ``$`` and therefore need no
77+
delayed-evaluation string substitution (we expect that there
78+
will be many of these and that we therefore get a pretty
79+
big win from avoiding string substitution)
8280
83-
strings that contain '$' and therefore need substitution
84-
(the hard case is things like '${TARGET.dir}/include',
85-
which require re-evaluation for every target + source)
81+
* Strings that contain ``$`` and therefore need substitution
82+
(the hard case is things like ``${TARGET.dir}/include``,
83+
which require re-evaluation for every target + source)
8684
87-
other objects (which may be something like an EntryProxy
88-
that needs a method called to return a Node)
85+
* Other objects (which may be something like an
86+
:class:`~SCons.Node.FS.EntryProxy`
87+
that needs a method called to return a Node)
8988
90-
Pre-identifying the type of each element in the PathList up-front
91-
and storing the type in the list of tuples is intended to reduce
92-
the amount of calculation when we actually do the substitution
93-
over and over for each target.
94-
"""
89+
Pre-identifying the type of each element in the :class:`PathList`
90+
up-front and storing the type in the list of tuples is intended to
91+
reduce the amount of calculation when we actually do the substitution
92+
over and over for each target.
93+
"""
94+
95+
def __init__(self, pathlist, split=True) -> None:
9596
if SCons.Util.is_String(pathlist):
9697
if split:
9798
pathlist = pathlist.split(os.pathsep)
@@ -152,34 +153,33 @@ class PathListCache:
152153
use the same Memoizer pattern that we use elsewhere to count cache
153154
hits and misses, which is very valuable.
154155
155-
Lookup keys in the cache are computed by the _PathList_key() method.
156+
Lookup keys in the cache are computed by the :meth:`_PathList_key` method.
156157
Cache lookup should be quick, so we don't spend cycles canonicalizing
157-
all forms of the same lookup key. For example, 'x:y' and ['x',
158-
'y'] logically represent the same list, but we don't bother to
158+
all forms of the same lookup key. For example, ``x:y`` and ``['x', 'y']``
159+
logically represent the same list, but we don't bother to
159160
split string representations and treat those two equivalently.
160161
(Note, however, that we do, treat lists and tuples the same.)
161162
162163
The main type of duplication we're trying to catch will come from
163164
looking up the same path list from two different clones of the
164-
same construction environment. That is, given
165+
same construction environment. That is, given::
165166
166167
env2 = env1.Clone()
167168
168-
both env1 and env2 will have the same CPPPATH value, and we can
169-
cheaply avoid re-parsing both values of CPPPATH by using the
169+
both ``env1`` and ``env2`` will have the same ``CPPPATH`` value, and we can
170+
cheaply avoid re-parsing both values of ``CPPPATH`` by using the
170171
common value from this cache.
171172
"""
172173
def __init__(self) -> None:
173174
self._memo = {}
174175

175176
def _PathList_key(self, pathlist):
176-
"""
177-
Returns the key for memoization of PathLists.
177+
"""Returns the key for memoization of PathLists.
178178
179179
Note that we want this to be pretty quick, so we don't completely
180180
canonicalize all forms of the same list. For example,
181-
'dir1:$ROOT/dir2' and ['$ROOT/dir1', 'dir'] may logically
182-
represent the same list if you're executing from $ROOT, but
181+
``dir1:$ROOT/dir2`` and ``['$ROOT/dir1', 'dir']`` may logically
182+
represent the same list if you're executing from ``$ROOT``, but
183183
we're not going to bother splitting strings into path elements,
184184
or massaging strings into Nodes, to identify that equivalence.
185185
We just want to eliminate obvious redundancy from the normal
@@ -191,9 +191,10 @@ def _PathList_key(self, pathlist):
191191

192192
@SCons.Memoize.CountDictCall(_PathList_key)
193193
def PathList(self, pathlist, split=True):
194-
"""
195-
Returns the cached _PathList object for the specified pathlist,
196-
creating and caching a new object as necessary.
194+
"""Entry point for getting PathLists.
195+
196+
Returns the cached :class:`_PathList` object for the specified
197+
pathlist, creating and caching a new object as necessary.
197198
"""
198199
pathlist = self._PathList_key(pathlist)
199200
try:
@@ -215,7 +216,8 @@ def PathList(self, pathlist, split=True):
215216

216217
PathList = PathListCache().PathList
217218

218-
219+
# TODO: removing the class object here means Sphinx doesn't pick up its
220+
# docstrings: they're fine for reading here, but are not in API Docs.
219221
del PathListCache
220222

221223
# Local Variables:

0 commit comments

Comments
 (0)