Skip to content
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

Fix Python3 Errors in Azure Cloud Module #26077

Merged
merged 1 commit into from Jun 29, 2017
Merged

Conversation

rajasaur
Copy link
Contributor

SUMMARY

When using Python3, the exec_module function errors out with a
unsupported operand type(s) for +: 'dict_keys' and 'list'
error when adding the .keys() to a static list. Use the explicit
list function to make a list of keys and then add to the ['tags'] list.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • cloud/azure
ANSIBLE VERSION
ansible 2.4.0 (python3_azure e9f6d02e69) last updated 2017/06/26 11:44:44 (GMT +550)
  config file = None
  configured module search path = ['/Users/raja/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /private/tmp/ansible/lib/ansible
  executable location = /private/tmp/ansible/bin/ansible
  python version = 3.6.0 (default, Dec 30 2016, 23:33:29) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
ADDITIONAL INFORMATION

When running azure modules under Python3, there are errors of the form:

TypeError: unsupported operand type(s) for +: 'dict_keys' and 'list'

This is because of calls like

self.module_arg_spec.keys() + ['tags']:

Replacing them with

list(self.module_arg_spec.keys()) + ['tags']:

fixes the issue. This is now done in the pull request for various azure sub commands

When using Python3, the exec_module function errors out with a
unsupported operand type(s) for +: 'dict_keys' and 'list'
error when adding the .keys() to a static list. Use the explicit
list function to make a list of keys and then add to the ['tags'] list.
@ansibot
Copy link
Contributor

ansibot commented Jun 26, 2017

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 azure bugfix_pull_request cloud committer_review In order to be merged, this PR must follow the certified review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 labels Jun 26, 2017
@trstringer
Copy link
Contributor

This looks good to me.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jun 26, 2017
@trstringer
Copy link
Contributor

I'm currently working on PR #24710 and I'd like to get this PR merged and rebased into my parent PR for it.

@nitzmahone since this is a multi-file PR and ansibot won't allow maintainers to automerge this one, could we get this merged in?

@abadger abadger merged commit 171d903 into ansible:devel Jun 29, 2017
@abadger
Copy link
Contributor

abadger commented Jun 29, 2017

Thanks for the work on this. Anytime I see combinations of lists like this which are then used just to do containment tests I think there is probably a better way. However, it isn't that important to have the perfect solution and this code is definitely an improvement. Merged to devel and cherry-picking to the 2.3 branch after 2.3.2 comes out (so it will be in 2.3.3 if we have a 2.3.3 release).

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 azure bug This issue/PR relates to a bug. cloud committer_review In order to be merged, this PR must follow the certified review workflow. module This issue/PR relates to a module. python3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants