RepoConfigLoader: python3.2 readfp deprecation
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 07:17:25 +0000 (00:17 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 07:17:25 +0000 (00:17 -0700)
pym/portage/repository/config.py

index d6a648ea04348bed2e6eb06fd2712bb8ce98ed13..06a4d94aa29109e7daecdb9666d97c1f1ecf6ee2 100644 (file)
@@ -326,7 +326,14 @@ class RepoConfigLoader(object):
        def _parse(paths, prepos, ignored_map, ignored_location_map):
                """Parse files in paths to load config"""
                parser = SafeConfigParser()
-               # use readfp in order to control decoding of unicode
+
+               # use read_file/readfp in order to control decoding of unicode
+               try:
+                       # Python >=3.2
+                       read_file = parser.read_file
+               except AttributeError:
+                       read_file = parser.readfp
+
                for p in paths:
                        f = None
                        try:
@@ -338,7 +345,7 @@ class RepoConfigLoader(object):
                                pass
                        else:
                                try:
-                                       parser.readfp(f)
+                                       read_file(f)
                                except ParsingError as e:
                                        writemsg(_unicode_decode(
                                                _("!!! Error while reading repo config file: %s\n")