New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ninja tool: using SCons warnings framework incorrectly #4036
Comments
What should we do here? I'd propose the three in |
That sounds like a reasonable fix to this. |
Well, it sounded good at the time. More questions now... In For those two, if the answer is Exception, I think of There's a second case in |
Try to normalize errors/warnings. One warning which was just a bare class instantition (thus, a no-op) now warns; two failures which used to raise SConsWarning now raise ImportError since that's what they are (has no visible effect to the user); another now raises UserError, as it is raised for an error in SConscripts. Fixes SCons#4036 Signed-off-by: Mats Wichmann <[email protected]>
(Edited to update) When I revisited a long pending set of checker gripes about the use of warnings, saw there are two instances in the ninja tool where a warning class is instantiated, but then nothing is done with it - it's not assigned to anything, it's not directly raised. Two other instances directly raise it, meaning it's not really a "warning" - it's actually an exception, it just happens to be the
SConsWarning
exception, which doesn't really make a lot of sense.Instantiated, unused:
https://github.com/SCons/scons/blob/120b2cd0b71363f63e8eb4898a44f1ba8a48af64/SCons/Tool/ninja/NinjaState.py#L810C1-L816C10
scons/SCons/Tool/ninja/__init__.py
Line 235 in 120b2cd
The first of those does intend a warning, it executes code after the call to the class constructor. The second looks like it actually wanted to raise an exception.
Directly
raise
:scons/SCons/Tool/ninja/__init__.py
Line 164 in 120b2cd
scons/SCons/Tool/ninja/__init__.py
Line 201 in 120b2cd
These two clearly intend execution to stop.
To fully use the scons framework you define a warning class and assign it to one of the categories (by inheriting from either
SConsWarning
orWarningOnByDefault
) and then invoke it in the desired way by callingSCons.Warnings.warn()
(though that's not absolutely necessary). Ninja does define its own warning:but it is never used.
The text was updated successfully, but these errors were encountered: