fix a couple misuses of textwrap.dedent

A backslash-escape of the last newline before a run of whitespace
leading to the indented string ending and function termination `)` does
not actually escape the entire line and make it do nothing. In fact what
it does is cause all that whitespace to be part of the preceding line,
and get printed.

Meanwhile the textwrap.dedent documentation states that lines with only
whitespace get normalized. When you *don't* mess with that final line,
dedent actually does the right thing and makes the output message end
with a single newline after the important text.
This commit is contained in:
Eli Schwartz 2022-02-16 22:52:52 -05:00
parent 996d471f5f
commit aa0450adda
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
2 changed files with 4 additions and 4 deletions

View File

@ -525,7 +525,7 @@ class Target(HoldableObject):
mlog.warning(textwrap.dedent(f'''\
Target "{self.name}" has a path separator in its name.
This is not supported, it can cause unexpected failures and will become
a hard error in the future.\
a hard error in the future.
'''))
self.install = False
self.build_always_stale = False
@ -1059,7 +1059,7 @@ class BuildTarget(Target):
is reserved for libraries built as part of this project. External
libraries must be passed using the dependencies keyword argument
instead, because they are conceptually "external dependencies",
just like those detected with the dependency() function.\
just like those detected with the dependency() function.
'''))
self.link(linktarget)
lwhole = extract_as_list(kwargs, 'link_whole')
@ -1112,7 +1112,7 @@ class BuildTarget(Target):
mlog.warning(textwrap.dedent('''\
Please do not define rpath with a linker argument, use install_rpath
or build_rpath properties instead.
This will become a hard error in a future Meson release.\
This will become a hard error in a future Meson release.
'''))
self.process_link_depends(kwargs.get('link_depends', []), environment)
# Target-specific include dirs must be added BEFORE include dirs from

View File

@ -196,7 +196,7 @@ class Lexer:
if match_text.find("\n") != -1:
mlog.warning(textwrap.dedent("""\
Newline character in a string detected, use ''' (three single quotes) for multiline strings instead.
This will become a hard error in a future Meson release.\
This will become a hard error in a future Meson release.
"""),
self.getline(line_start),
str(lineno),