Repository: ansible-collections/community.general

Issue:
jira module search operation is broken in python 2
##### SUMMARY
In the current master branch, in the jira module's search operation, there's a call to `urllib.request.pathname2url` which works fine in Python 3 but throws an error in Python 2. It's because of the changes to the `urlib` component in Python 3 which changed the location of the `pathname2url` function. The current code is not Python 2 compatible.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
jira

##### ANSIBLE VERSION
I'm using 2.9, but it's not relevant here because the jira module I'm using is not released yet. See https://github.com/ansible-collections/community.general/pull/22 where this code was added a short time ago.

I am seeing this error on this workstation using `connection: local`, so I presume it's using python 2 when the module runs:
```
$ which python
/usr/bin/python
$ `which python` --version
Python 2.7.16
```
Anyway:
```
ansible 2.9.5
  config file = /home/sbaird/dev/ansible-playbooks/errata-tool-playbooks/ansible.cfg
  configured module search path = ['/home/sbaird/dev/ansible-playbooks/errata-tool-playbooks/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.4 (default, Jul  9 2019, 16:32:37) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
```

##### CONFIGURATION

##### OS / ENVIRONMENT
Fedora and RHEL

##### STEPS TO REPRODUCE
* Try using jira search operation on a system with Python 2 using the yet unreleased jira module in the latest master branch, (from https://github.com/ansible-collections/community.general/pull/22).

##### EXPECTED RESULTS
* Task suceeds.

##### ACTUAL RESULTS
* Tasks fails with an error something like this:
```
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_jira_future_payload_7sKAgF/ansible_jira_future_payload.zip/ansible/modules/jira_future.py", line 541, in main
  File "/tmp/ansible_jira_future_payload_7sKAgF/ansible_jira_future_payload.zip/ansible/modules/jira_future.py", line 422, in search
fatal: [errata-web-01.dev.eng.bne.redhat.com]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "assignee": null,
            ...snip the rest of the module args...
        }
    },
    "msg": "'module' object has no attribute 'request'"
}
```



Discussion:

Resolving patch:
diff --git a/plugins/modules/web_infrastructure/jira.py b/plugins/modules/web_infrastructure/jira.py
--- a/plugins/modules/web_infrastructure/jira.py
+++ b/plugins/modules/web_infrastructure/jira.py
@@ -286,7 +286,9 @@
 import base64
 import json
 import sys
-import urllib
+
+from ansible.module_utils.six.moves.urllib.request import pathname2url
+
 from ansible.module_utils._text import to_text, to_bytes
 
 from ansible.module_utils.basic import AnsibleModule
@@ -401,10 +403,10 @@ def fetch(restbase, user, passwd, params):
 
 
 def search(restbase, user, passwd, params):
-    url = restbase + '/search?jql=' + urllib.request.pathname2url(params['jql'])
+    url = restbase + '/search?jql=' + pathname2url(params['jql'])
     if params['fields']:
         fields = params['fields'].keys()
-        url = url + '&fields=' + '&fields='.join([urllib.request.pathname2url(f) for f in fields])
+        url = url + '&fields=' + '&fields='.join([pathname2url(f) for f in fields])
     if params['maxresults']:
         url = url + '&maxResults=' + str(params['maxresults'])
     ret = get(url, user, passwd, params['timeout'])


Test patch: