launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26416
[Merge] ~cjwatson/launchpad:py3-configparser-deprecation into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-configparser-deprecation into launchpad:master.
Commit message:
Fix configparser DeprecationWarning on Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398641
I would have added something to lp.services.compat, but it didn't seem worth bothering given that there were only two occurrences.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-configparser-deprecation into launchpad:master.
diff --git a/lib/lp/services/rabbit/tests/test_server.py b/lib/lp/services/rabbit/tests/test_server.py
index fc56263..1ab2d5a 100644
--- a/lib/lp/services/rabbit/tests/test_server.py
+++ b/lib/lp/services/rabbit/tests/test_server.py
@@ -8,6 +8,7 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
import io
+import sys
from fixtures import EnvironmentVariableFixture
@@ -30,7 +31,11 @@ class TestRabbitServer(TestCase):
# RabbitServer pokes some .ini configuration into its config.
fixture = self.useFixture(RabbitServer())
service_config = SafeConfigParser()
- service_config.readfp(io.StringIO(fixture.config.service_config))
+ if sys.version_info[:2] >= (3, 2):
+ read_file = service_config.read_file
+ else:
+ read_file = service_config.readfp
+ read_file(io.StringIO(fixture.config.service_config))
self.assertEqual(["rabbitmq"], service_config.sections())
expected = {
"host": "localhost:%d" % fixture.config.port,
diff --git a/lib/lp/services/scripts/base.py b/lib/lp/services/scripts/base.py
index 1a47b2d..bb4490b 100644
--- a/lib/lp/services/scripts/base.py
+++ b/lib/lp/services/scripts/base.py
@@ -472,7 +472,11 @@ def cronscript_enabled(control_url, name, log):
# traceback and continue on using the defaults.
try:
with response:
- cron_config.readfp(io.StringIO(response.text))
+ if sys.version_info[:2] >= (3, 2):
+ read_file = cron_config.read_file
+ else:
+ read_file = cron_config.readfp
+ read_file(io.StringIO(response.text))
except Exception:
log.exception("Error parsing %s", control_url)