Skip to content

Commit bc99432

Browse files
mwilckfelixfontein
andauthored
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 ansible/ansible#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 Co-authored-by: Felix Fontein <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]>
1 parent 2428c0d commit bc99432

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- 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).

plugins/modules/zypper_repository.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142

143143
from ansible.module_utils.urls import fetch_url
144144
from ansible.module_utils.common.text.converters import to_text
145+
from ansible.module_utils.six import PY3
145146
from ansible.module_utils.six.moves import configparser, StringIO
146147
from io import open
147148

@@ -407,7 +408,10 @@ def exit_unchanged():
407408

408409
repofile = configparser.ConfigParser()
409410
try:
410-
repofile.readfp(StringIO(repofile_text))
411+
if PY3:
412+
repofile.read_file(StringIO(repofile_text))
413+
else:
414+
repofile.readfp(StringIO(repofile_text))
411415
except configparser.Error:
412416
module.fail_json(msg='Invalid format, .repo file could not be parsed')
413417

0 commit comments

Comments
 (0)