Resolve variable masking issue in ui.browseableMessage #16380
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fix-up of PR from GHSA-xg6w-23rw-39r8.
Summary of the issue:
A masking issue was found in
ui.browseableMessage
where we try to call the module level functionmessage
but it is masked by the local variablemessage
which is an argument ofui.browseableMessage
.Description of user facing changes
In case an installation cannot create a
Scripting.Dictionary
COM object, a message will now be reported.Description of development approach
I access the module level
message
function throughglobals()
dictionary and store it in a new local variable to use it.It would have been cleaner to rename the argument of
ui.browseableMessage
but I have not done so because changing the signature of a function is API-breaking.I have also caught one more exception type because I have realized while testing that calling
comtypes.client.CreateObject
with an unknown class string raisesOSError
.Testing strategy:
Manual test: modify the class string to force the exception. E.g. call:
comtypes.client.CreateObject('Scripting.TestUnexistingClass')
Known issues with pull request:
None
Change log
Not needed: I guess no one has ever fallen in this code path.
Note
I have found this issue while doing tests.
But fortunately, I have not found any plateform where
Scripting.Dictionary
cannot be created.Code Review Checklist: