summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2023-03-28 10:41:02 -0500
committerGitHub <noreply@github.com>2023-03-28 17:41:02 +0200
commit9faf94468bd2e2b622908865d8e67d8dfdfccbd5 (patch)
tree098b8a94e4290e9e5b157174effc318a5cbf862f
parentbf74f390afaf2eaa8782ca823e29f2c0c39666f3 (diff)
downloadansible-9faf94468bd2e2b622908865d8e67d8dfdfccbd5.tar.gz
Enforce that `Display.display` requires a `str` (#80327)
* Enforce that Display.display requires a str * clog frag * ci_complete
-rw-r--r--changelogs/fragments/display-display-str-only.yml2
-rw-r--r--lib/ansible/utils/display.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/changelogs/fragments/display-display-str-only.yml b/changelogs/fragments/display-display-str-only.yml
new file mode 100644
index 0000000000..af3061098f
--- /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 16966aaf0d..b4ff01c006 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