Skip to content

Commit eb940d9

Browse files
committed
Subst docstrings: add note on string containers [skip ci]
Two string containers defined here, Literal and SepcialAttrWrapper, do not subclass UserString. Add a note on that for uses which might expect them to be identifiable as string types. CmdStringHolder does subclass UserString, so it doesn't have this caveat. Signed-off-by: Mats Wichmann <[email protected]>
1 parent 9352481 commit eb940d9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

SCons/Subst.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class Literal:
8585
The substitution logic will not change the wrapped string.
8686
When passed to the command interpreter, all special
8787
characters will be escaped and/or the string quoted.
88+
89+
Note that since we do not subclass :mod:`~collections.UserString`,
90+
:func:`~SCons.Util.sctypes.is_String` will not identify this as a string,
91+
and :func:`~SCons.Util.sctypes.to_String` won't return the enclosed string.
8892
"""
8993

9094
def __init__(self, lstr) -> None:
@@ -131,8 +135,12 @@ class SpecialAttrWrapper:
131135
so we can return some canonical string during signature
132136
calculation to avoid unnecessary rebuilds.
133137
134-
If the *for_signature* parameter if supplied at creation time,
138+
If the *for_signature* parameter is supplied at creation time,
135139
:meth:`for_signature` will return that when called, else the original.
140+
141+
Note that since we do not subclass :mod:`~collections.UserString`,
142+
:func:`~SCons.Util.sctypes.is_String` will not identify this as a string,
143+
and :func:`~SCons.Util.sctypes.to_String` won't return the enclosed string.
136144
"""
137145

138146
def __init__(self, lstr: str, for_signature: str | None = None) -> None:

0 commit comments

Comments
 (0)