← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jameinel/launchpad/py27-parse-response-1018768 into lp:launchpad

 

John A Meinel has proposed merging lp:~jameinel/launchpad/py27-parse-response-1018768 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jameinel/launchpad/py27-parse-response-1018768/+merge/112537

This adds a compatibility check for a change to xmlrpclib.Transport in python 2.7 vs 2.6.

They changed the '_parse_response' function, making it public, and removing the 'sock' attribute (for which we were passing None anyway).

This adds 6 lines of code, however when an official switch to python-2.7 is made, all of those extra lines can just be removed.
-- 
https://code.launchpad.net/~jameinel/launchpad/py27-parse-response-1018768/+merge/112537
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jameinel/launchpad/py27-parse-response-1018768 into lp:launchpad.
=== modified file 'lib/lp/bugs/externalbugtracker/xmlrpc.py'
--- lib/lp/bugs/externalbugtracker/xmlrpc.py	2011-02-08 20:52:21 +0000
+++ lib/lp/bugs/externalbugtracker/xmlrpc.py	2012-06-28 10:50:26 +0000
@@ -114,4 +114,10 @@
                 request.get_full_url(), he.code, he.msg, he.hdrs)
         else:
             traceback_info(response)
-            return self._parse_response(StringIO(response), None)
+            # In Python2.6 the api is self._parse_response, in 2.7 it is
+            # self.parse_response and no longer takes the 'sock' argument
+            parse = getattr(self, '_parse_response', None)
+            if parse is not None:
+                # Compatibility with python 2.6
+                return parse(StringIO(response), None)
+            return self.parse_response(StringIO(response))


Follow ups