{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/5840","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/5840/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/5840/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/5840/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/5840","id":193740457,"number":5840,"title":"replace: TypeError when run under Python 3","user":{"login":"cederberg","id":11371,"avatar_url":"https://avatars.githubusercontent.com/u/11371?v=3","gravatar_id":"","url":"https://api.github.com/users/cederberg","html_url":"https://github.com/cederberg","followers_url":"https://api.github.com/users/cederberg/followers","following_url":"https://api.github.com/users/cederberg/following{/other_user}","gists_url":"https://api.github.com/users/cederberg/gists{/gist_id}","starred_url":"https://api.github.com/users/cederberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cederberg/subscriptions","organizations_url":"https://api.github.com/users/cederberg/orgs","repos_url":"https://api.github.com/users/cederberg/repos","events_url":"https://api.github.com/users/cederberg/events{/privacy}","received_events_url":"https://api.github.com/users/cederberg/received_events","type":"User","site_admin":false},"labels":[{"id":437720380,"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/affects_2.2","name":"affects_2.2","color":"5319e7","default":false},{"id":132571937,"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":414073372,"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/waiting_on_maintainer","name":"waiting_on_maintainer","color":"d93f0b","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-06T10:51:09Z","updated_at":"2016-12-09T19:47:07Z","closed_at":"2016-12-09T19:47:07Z","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n - files/replace\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.2.0.0 (detached HEAD cdec853e37) last updated 2016/12/01 10:23:30 (GMT +200)\r\n  lib/ansible/modules/core: (detached HEAD fe9c56a003) last updated 2016/12/01 10:24:42 (GMT +200)\r\n  lib/ansible/modules/extras: (detached HEAD f564e77a08) last updated 2016/12/01 10:24:42 (GMT +200)\r\n  config file = \r\n  configured module search path = ['/Users/per/Projects/servers/submodules/ansible/library']\r\n```\r\n\r\n##### CONFIGURATION\r\n - ansible_python_interpreter=/usr/bin/python3\r\n\r\n##### OS / ENVIRONMENT\r\n - Local: MacOS\r\n- Remote: Ubuntu 16.04, with Python 3.5.2\r\n\r\n##### SUMMARY\r\nReplace fails with a TypeError when run under Python 3\r\n\r\n##### STEPS TO REPRODUCE\r\n```\r\nansible *** -m replace \\\r\n    -a \"dest=/etc/lsb-release regexp=nomatchfound replace=nomatchfound\"\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nNo replacement (since regex doesn't match).\r\n\r\n##### ACTUAL RESULTS\r\nCommand fails with error: `TypeError: cannot use a string pattern on a bytes-like object`\r\n\r\n```\r\n*** | FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"module_stderr\": \"Shared connection to *** closed.\\r\\n\", \r\n    \"module_stdout\": \"Traceback (most recent call last):\\r\\n  File \\\"/tmp/ansible_1wjonocj/ansible_module_replace.py\\\", line 180, in <module>\\r\\n    main()\\r\\n  File \\\"/tmp/ansible_1wjonocj/ansible_module_replace.py\\\", line 153, in main\\r\\n    result = re.subn(mre, params['replace'], contents, 0)\\r\\n  File \\\"/usr/lib/python3.5/re.py\\\", line 193, in subn\\r\\n    return _compile(pattern, flags).subn(repl, string, count)\\r\\nTypeError: cannot use a string pattern on a bytes-like object\\r\\n\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\n```\r\n\r\nReadable traceback (from above):\r\n```\r\nTraceback (most recent call last):\r\n  File \\\"/tmp/ansible_1wjonocj/ansible_module_replace.py\\\", line 180, in <module>\r\n    main()\r\n  File \\\"/tmp/ansible_1wjonocj/ansible_module_replace.py\\\", line 153, in main\r\n    result = re.subn(mre, params['replace'], contents, 0)\r\n  File \\\"/usr/lib/python3.5/re.py\\\", line 193, in subn\r\n    return _compile(pattern, flags).subn(repl, string, count)\r\nTypeError: cannot use a string pattern on a bytes-like object\r\n```\r\n"}}
{"actor":{"display_login":"ansibot"}}