-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module_utils.urls - Encode the proxy connect as binary #30811
Merged
abadger
merged 3 commits into
ansible:devel
from
DamianZaremba:urls_proxy_python3_bugfix
Sep 29, 2017
Merged
module_utils.urls - Encode the proxy connect as binary #30811
abadger
merged 3 commits into
ansible:devel
from
DamianZaremba:urls_proxy_python3_bugfix
Sep 29, 2017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Under Python3 the sendall method expects binary not a string. Prior to this change the below exception was being thrown; Traceback (most recent call last): File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 1044, in fetch_url client_key=client_key, cookies=cookies) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 951, in open_url r = urllib_request.urlopen(*urlopen_args) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 524, in open req = meth(req) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 729, in http_request s.sendall((self.CONNECT_COMMAND % (self.hostname, self.port)).decode()) AttributeError: 'str' object has no attribute 'decode' Encoding the value is inline with the lines below (Proxy-Authorization etc) which are being sent as binary.
ansibot
added
affects_2.5
This issue/PR affects Ansible v2.5
bugfix_pull_request
module_utils/urls
needs_triage
Needs a first human triage before being processed.
python3
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
labels
Sep 24, 2017
sivel
reviewed
Sep 25, 2017
lib/ansible/module_utils/urls.py
Outdated
@@ -728,7 +728,7 @@ def http_request(self, req): | |||
port = proxy_parts.get('port') or 443 | |||
s = socket.create_connection((proxy_parts.get('hostname'), port)) | |||
if proxy_parts.get('scheme') == 'http': | |||
s.sendall(self.CONNECT_COMMAND % (self.hostname, self.port)) | |||
s.sendall((self.CONNECT_COMMAND % (self.hostname, self.port)).encode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should likely be using ansible.module_utils._text.to_bytes
instead of encode
alikins
removed
the
needs_triage
Needs a first human triage before being processed.
label
Sep 25, 2017
Updated to use to_bytes, I clearly didn't read the rest of the file... |
abadger
pushed a commit
that referenced
this pull request
Sep 29, 2017
* module_utils.urls - Encode the proxy connect as binary Under Python3 the sendall method expects binary not a string. Prior to this change the below exception was being thrown; Traceback (most recent call last): File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 1044, in fetch_url client_key=client_key, cookies=cookies) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 951, in open_url r = urllib_request.urlopen(*urlopen_args) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 524, in open req = meth(req) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 729, in http_request s.sendall((self.CONNECT_COMMAND % (self.hostname, self.port)).decode()) AttributeError: 'str' object has no attribute 'decode' Encoding the value is inline with the lines below (Proxy-Authorization etc) which are being sent as binary. (cherry picked from commit 92f777e)
Merged to devel and backported to stable-2.4 for the 2.4.1beta2 release. |
prasadkatti
pushed a commit
to prasadkatti/ansible
that referenced
this pull request
Oct 1, 2017
* module_utils.urls - Encode the proxy connect as binary Under Python3 the sendall method expects binary not a string. Prior to this change the below exception was being thrown; Traceback (most recent call last): File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 1044, in fetch_url client_key=client_key, cookies=cookies) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 951, in open_url r = urllib_request.urlopen(*urlopen_args) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 524, in open req = meth(req) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 729, in http_request s.sendall((self.CONNECT_COMMAND % (self.hostname, self.port)).decode()) AttributeError: 'str' object has no attribute 'decode' Encoding the value is inline with the lines below (Proxy-Authorization etc) which are being sent as binary.
BondAnthony
pushed a commit
to BondAnthony/ansible
that referenced
this pull request
Oct 5, 2017
* module_utils.urls - Encode the proxy connect as binary Under Python3 the sendall method expects binary not a string. Prior to this change the below exception was being thrown; Traceback (most recent call last): File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 1044, in fetch_url client_key=client_key, cookies=cookies) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 951, in open_url r = urllib_request.urlopen(*urlopen_args) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/opt/blue-python/3.6/lib/python3.6/urllib/request.py", line 524, in open req = meth(req) File "/tmp/ansible_umxox7_x/ansible_modlib.zip/ansible/module_utils/urls.py", line 729, in http_request s.sendall((self.CONNECT_COMMAND % (self.hostname, self.port)).decode()) AttributeError: 'str' object has no attribute 'decode' Encoding the value is inline with the lines below (Proxy-Authorization etc) which are being sent as binary.
ansibot
added
bug
This issue/PR relates to a bug.
and removed
bugfix_pull_request
labels
Mar 6, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
affects_2.5
This issue/PR affects Ansible v2.5
bug
This issue/PR relates to a bug.
module_utils/urls
python3
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Under Python3 the sendall method expects binary not a string.
Prior to this change the below exception was being thrown;
Encoding the value is inline with the lines below (Proxy-Authorization etc) which are being sent as binary.
ISSUE TYPE
COMPONENT NAME
module_utils/urls.py
ANSIBLE VERSION
(This is a straight package of the upstream release)
ADDITIONAL INFORMATION
This can be replicated using the below eos_config task config;