mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
[PR #10223/bc99432f backport][stable-10] zypper_repository: fix usage of removed method ConfigParser.readfp() (#10236)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
zypper_repository: fix usage of removed method ConfigParser.readfp() (#10223)
* zypper_repository: fix usage of removed method ConfigParser.readfp()
ConfigParser.readfp() has been removed in python 3.12.
See similar fix e.g. in https://github.com/ansible/ansible/pull/81657
This fixes the error message:
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
* Update changelogs/fragments/10222-zypper_repository-readfp.yml
---------
(cherry picked from commit bc99432f89
)
Co-authored-by: Martin Wilck <mwilck@suse.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
0478b0c5a1
commit
e8ff74f077
2 changed files with 7 additions and 1 deletions
2
changelogs/fragments/10222-zypper_repository-readfp.yml
Normal file
2
changelogs/fragments/10222-zypper_repository-readfp.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- zypper_repository - make compatible with Python 3.12+ (https://github.com/ansible-collections/community.general/issues/10222, https://github.com/ansible-collections/community.general/pull/10223).
|
|
@ -142,6 +142,7 @@ from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
|||
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible.module_utils.six import PY3
|
||||
from ansible.module_utils.six.moves import configparser, StringIO
|
||||
from io import open
|
||||
|
||||
|
@ -407,6 +408,9 @@ def main():
|
|||
|
||||
repofile = configparser.ConfigParser()
|
||||
try:
|
||||
if PY3:
|
||||
repofile.read_file(StringIO(repofile_text))
|
||||
else:
|
||||
repofile.readfp(StringIO(repofile_text))
|
||||
except configparser.Error:
|
||||
module.fail_json(msg='Invalid format, .repo file could not be parsed')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue