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

Proposed by John A Meinel
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 15515
Proposed branch: lp:~jameinel/launchpad/py27-parse-response-1018768
Merge into: lp:launchpad
Diff against target: 15 lines (+7/-1)
1 file modified
lib/lp/bugs/externalbugtracker/xmlrpc.py (+7/-1)
To merge this branch: bzr merge lp:~jameinel/launchpad/py27-parse-response-1018768
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Review via email: mp+112537@code.launchpad.net

Commit message

Add compatibility for python2.7's xmlrpclib.Transport.parse_response

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/externalbugtracker/xmlrpc.py'
2--- lib/lp/bugs/externalbugtracker/xmlrpc.py 2011-02-08 20:52:21 +0000
3+++ lib/lp/bugs/externalbugtracker/xmlrpc.py 2012-06-28 10:50:26 +0000
4@@ -114,4 +114,10 @@
5 request.get_full_url(), he.code, he.msg, he.hdrs)
6 else:
7 traceback_info(response)
8- return self._parse_response(StringIO(response), None)
9+ # In Python2.6 the api is self._parse_response, in 2.7 it is
10+ # self.parse_response and no longer takes the 'sock' argument
11+ parse = getattr(self, '_parse_response', None)
12+ if parse is not None:
13+ # Compatibility with python 2.6
14+ return parse(StringIO(response), None)
15+ return self.parse_response(StringIO(response))