From 6bb7bd760f9ed53c6fb0399e4921ffb5648cabeb Mon Sep 17 00:00:00 2001 From: sivel / Matt Martz Date: Mon, 24 Nov 2025 11:33:45 -0600 Subject: [PATCH] Fix escaping issue in ansiballz wrapper for sitecustomize (#86236) * Fix escaping issue in ansiballz wrapper for sitecustomize * add clog frag --- changelogs/fragments/ansiballz-wrapper-sitecustomize.yml | 2 ++ lib/ansible/_internal/_ansiballz/_wrapper.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ansiballz-wrapper-sitecustomize.yml diff --git a/changelogs/fragments/ansiballz-wrapper-sitecustomize.yml b/changelogs/fragments/ansiballz-wrapper-sitecustomize.yml new file mode 100644 index 00000000000..36f2787cfc9 --- /dev/null +++ b/changelogs/fragments/ansiballz-wrapper-sitecustomize.yml @@ -0,0 +1,2 @@ +bugfixes: +- modules - fix AnsiballZ wrapper code escaping of sitecustomize diff --git a/lib/ansible/_internal/_ansiballz/_wrapper.py b/lib/ansible/_internal/_ansiballz/_wrapper.py index 4d9d9b4f4bf..43cf6a69bda 100644 --- a/lib/ansible/_internal/_ansiballz/_wrapper.py +++ b/lib/ansible/_internal/_ansiballz/_wrapper.py @@ -121,7 +121,7 @@ def _ansiballz_main( z = zipfile.ZipFile(modlib_path, mode='a') # py3: modlib_path will be text, py2: it's bytes. Need bytes at the end - sitecustomize = u'import sys\\nsys.path.insert(0,"%s")\\n' % modlib_path + sitecustomize = 'import sys\nsys.path.insert(0, "%s")\n' % modlib_path sitecustomize = sitecustomize.encode('utf-8') # Use a ZipInfo to work around zipfile limitation on hosts with # clocks set to a pre-1980 year (for instance, Raspberry Pi)