# Buggy code
def __init__(self, src, dest, file_args, module):
    self.src = src
    self.dest = dest
    self.file_args = file_args
    self.opts = module.params["extra_opts"]
    self.module = module
    if self.module.check_mode:
        self.module.exit_json(
            skipped=True,
            msg="remote module (%s) does not support check mode when using gtar"
            % self.module._name,
        )
    self.excludes = [path.rstrip("/") for path in self.module.params["exclude"]]
    # Prefer gtar (GNU tar) as it supports the compression options -z, -j and -J
    self.cmd_path = self.module.get_bin_path("gtar", None)
    if not self.cmd_path:
        # Fallback to tar
        self.cmd_path = self.module.get_bin_path("tar")
    self.zipflag = "-z"
    self._files_in_archive = []

    if self.cmd_path:
        self.tar_type = self._get_tar_type()
    else:
        self.tar_type = None


# Traceback (nUnicodeEncodeError)
TASK [unarchive : test that unarchive works with an archive that contains non-ascii filenames] **************************************************************************
fatal: [testhost]: FAILED! => {"changed": false, "module_stderr": "Shared connection to localhost closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1561576726.3763218-37161750934991/AnsiballZ_unarchive.py\", line 139, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1561576726.3763218-37161750934991/AnsiballZ_unarchive.py\", line 131, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1561576726.3763218-37161750934991/AnsiballZ_unarchive.py\", line 65, in invoke_module\r\n    spec.loader.exec_module(module)\r\n  File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module\r\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\r\n  File \"/tmp/ansible_unarchive_payload_o9_x930g/__main__.py\", line 909, in <module>\r\n  File \"/tmp/ansible_unarchive_payload_o9_x930g/__main__.py\", line 859, in main\r\n  File \"/usr/local/lib/python3.6/genericpath.py\", line 42, in isdir\r\n    st = os.stat(s)\r\nUnicodeEncodeError: 'ascii' codec can't encode characters in position 51-54: ordinal not in range(128)\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

# Fixed code
def __init__(self, src, b_dest, file_args, module):
    self.src = src
    self.b_dest = b_dest
    self.file_args = file_args
    self.opts = module.params["extra_opts"]
    self.module = module
    if self.module.check_mode:
        self.module.exit_json(
            skipped=True,
            msg="remote module (%s) does not support check mode when using gtar"
            % self.module._name,
        )
    self.excludes = [path.rstrip("/") for path in self.module.params["exclude"]]
    # Prefer gtar (GNU tar) as it supports the compression options -z, -j and -J
    self.cmd_path = self.module.get_bin_path("gtar", None)
    if not self.cmd_path:
        # Fallback to tar
        self.cmd_path = self.module.get_bin_path("tar")
    self.zipflag = "-z"
    self._files_in_archive = []

    if self.cmd_path:
        self.tar_type = self._get_tar_type()
    else:
        self.tar_type = None