Skip to content

Commit

Permalink
wip: for patch
Browse files Browse the repository at this point in the history
  • Loading branch information
amarao committed Feb 29, 2024
1 parent ddff0b0 commit b6d3df4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion integration_tests/test3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
hosts: test
gather_facts: false
tasks:
- name: "known bug to cause trace for mitogen with ansible 2.16"
# https://github.com/mitogen-hq/mitogen/issues/1034
- name: "bug 1034, known bug to cause trace for mitogen with ansible 2.16"
check_mode: true
ansible.builtin.package:
name: "vim"
Expand Down
38 changes: 38 additions & 0 deletions plugins/strategy/patching.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,51 @@
import os


# Written by @AKrumov
# https://github.com/mitogen-hq/mitogen/issues/1034#issuecomment-1851557386
patch_1034_v1 = """
--- core.old 2024-02-29 14:53:29.478417261 +0200
+++ core.py 2024-02-29 14:53:48.846102667 +0200
@@ -842,11 +842,15 @@
s, n = LATIN1_CODEC.encode(s)
return s
+ def _unpickle_ansible_unsafe_text(self, serialized_obj):
+ return serialized_obj
+
def _find_global(self, module, func):
\"""
Return the class implementing `module_name.class_name` or raise
`StreamError` if the module is not whitelisted.
\"""
+ print(module, __name__)
if module == __name__:
if func == '_unpickle_call_error' or func == 'CallError':
return _unpickle_call_error
@@ -860,6 +864,8 @@
return Secret
elif func == 'Kwargs':
return Kwargs
+ elif module == 'ansible.utils.unsafe_proxy' and func == 'AnsibleUnsafeText':
+ return self._unpickle_ansible_unsafe_text
elif module == '_codecs' and func == 'encode':
return self._unpickle_bytes
elif module == '__builtin__' and func == 'bytes':
"""


def loaders_path():
import ansible_mitogen

loaders_path = os.path.join(os.path.dirname(ansible_mitogen.__file__), "loaders.py")
return loaders_path


def core_path():
from mitogen import core
return core.__file__


class patch_version(ContextDecorator):
ORIG_LINE = "ANSIBLE_VERSION_MAX = (2, 13)\n"
PATCH_LINE = "ANSIBLE_VERSION_MAX = (2, 16)\n"
Expand Down

0 comments on commit b6d3df4

Please sign in to comment.