diff --git a/changelogs/fragments/display-display-str-only.yml b/changelogs/fragments/display-display-str-only.yml new file mode 100644 index 00000000000..af3061098f4 --- /dev/null +++ b/changelogs/fragments/display-display-str-only.yml @@ -0,0 +1,2 @@ +bugfixes: +- Perform type check on data passed to Display.display to enforce the requirement of being given a python3 unicode string diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index 16966aaf0d7..b4ff01c0060 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -326,6 +326,9 @@ class Display(metaclass=Singleton): Note: msg *must* be a unicode string to prevent UnicodeError tracebacks. """ + if not isinstance(msg, str): + raise TypeError(f'Display message must be str, not: {msg.__class__.__name__}') + if self._final_q: # If _final_q is set, that means we are in a WorkerProcess # and instead of displaying messages directly from the fork