[Python-modules-commits] r31680 - in packages/lazr.restfulclient/trunk/debian (4 files)

xnox at users.alioth.debian.org xnox at users.alioth.debian.org
Wed Jan 21 18:58:32 UTC 2015


    Date: Wednesday, January 21, 2015 @ 18:58:31
  Author: xnox
Revision: 31680

Fix json loads (LP: #1403524).

Added:
  packages/lazr.restfulclient/trunk/debian/patches/
  packages/lazr.restfulclient/trunk/debian/patches/lp1403524.patch
  packages/lazr.restfulclient/trunk/debian/patches/series
Modified:
  packages/lazr.restfulclient/trunk/debian/changelog

Modified: packages/lazr.restfulclient/trunk/debian/changelog
===================================================================
--- packages/lazr.restfulclient/trunk/debian/changelog	2015-01-21 13:35:54 UTC (rev 31679)
+++ packages/lazr.restfulclient/trunk/debian/changelog	2015-01-21 18:58:31 UTC (rev 31680)
@@ -1,3 +1,9 @@
+lazr.restfulclient (0.13.4-3) UNRELEASED; urgency=medium
+
+  * Fix json loads (LP: #1403524).
+
+ -- Dimitri John Ledkov <dimitri.j.ledkov at linux.intel.com>  Wed, 21 Jan 2015 18:57:29 +0000
+
 lazr.restfulclient (0.13.4-2) experimental; urgency=medium
 
   * Correct upstream tarball release... use .bz2 tarball

Added: packages/lazr.restfulclient/trunk/debian/patches/lp1403524.patch
===================================================================
--- packages/lazr.restfulclient/trunk/debian/patches/lp1403524.patch	                        (rev 0)
+++ packages/lazr.restfulclient/trunk/debian/patches/lp1403524.patch	2015-01-21 18:58:31 UTC (rev 31680)
@@ -0,0 +1,103 @@
+Description: Fix json loads calls bytes vs unicode.
+Origin: commit, revision id: dimitri.j.ledkov at intel.com-20150121185019-7lhyq3goy2dpgvid
+Author: Dimitri John Ledkov <dimitri.j.ledkov at intel.com>
+Bug: https://launchpad.net/bugs/1403524
+Last-Update: 2015-01-21
+X-Bzr-Revision-Id: dimitri.j.ledkov at intel.com-20150121185019-7lhyq3goy2dpgvid
+
+=== modified file 'src/lazr/restfulclient/resource.py'
+--- old/src/lazr/restfulclient/resource.py	2014-07-28 15:35:35 +0000
++++ new/src/lazr/restfulclient/resource.py	2015-01-21 18:50:19 +0000
+@@ -381,7 +381,7 @@
+             representation = self._root._browser.get(self._wadl_resource)
+             if isinstance(representation, binary_type):
+                 representation = representation.decode('utf-8')
+-            representation = loads(text_type(representation))
++            representation = loads(representation)
+ 
+             # In rare cases, the resource type served by the
+             # server conflicts with the type the client thought
+@@ -530,8 +530,10 @@
+                 url = url[1:]
+             url = str(self._root_uri.append(url))
+         document = self._browser.get(url)
++        if isinstance(document, binary_type):
++            document = document.decode('utf-8')
+         try:
+-            representation = loads(text_type(document))
++            representation = loads(document)
+         except ValueError:
+             raise ValueError("%s doesn't serve a JSON document." % url)
+         type_link = representation.get("resource_type_link")
+@@ -647,13 +649,18 @@
+             # The operation returned a document with nothing
+             # special about it.
+             if content_type == self.JSON_MEDIA_TYPE:
+-                return loads(text_type(content))
++                if isinstance(content, binary_type):
++                    content = content.decode('utf-8')
++                return loads(content)
+             # We don't know how to process the content.
+             return content
+ 
+         # The operation returned a representation of some
+         # resource. Instantiate a Resource object for it.
+-        document = loads(text_type(content))
++        if isinstance(content, binary_type):
++            content = content.decode('utf-8')
++        
++        document = loads(content)
+         if document is None:
+             # The operation returned a null value.
+             return document
+@@ -777,7 +784,9 @@
+         if response.status == 209 and content_type == self.JSON_MEDIA_TYPE:
+             # The server sent back a new representation of the object.
+             # Use it in preference to the existing representation.
+-            new_representation = loads(text_type(content))
++            if isinstance(content, binary_type):
++                content = content.decode('utf-8')
++            new_representation = loads(content)
+             self._wadl_resource.representation = new_representation
+             self._wadl_resource.media_type = content_type
+ 
+@@ -822,8 +831,10 @@
+             next_link = current_page.get('next_collection_link')
+             if next_link is None:
+                 break
+-            current_page = loads(
+-                text_type(self._root._browser.get(URI(next_link))))
++            next_get = self._root._browser.get(URI(next_link))
++            if isinstance(next_get, binary_type):
++                next_get = next_get.decode('utf-8')
++            current_page = loads(next_get)
+ 
+     def __getitem__(self, key):
+         """Look up a slice, or a subordinate resource by index.
+@@ -895,8 +906,10 @@
+ 
+         # Iterate over pages until we have the correct number of entries.
+         while more_needed > 0 and page_url is not None:
+-            representation = loads(
+-                text_type(self._root._browser.get(page_url)))
++            page_get = self._root._browser.get(page_url)
++            if isinstance(page_get, binary_type):
++                page_get = page_get.decode('utf-8')
++            representation = loads(page_get)
+             current_page_entries = representation['entries']
+             entry_dicts += current_page_entries[:more_needed]
+             more_needed = desired_size - len(entry_dicts)
+@@ -1020,8 +1033,10 @@
+             # retrieve a representation of the resource and see how
+             # the resource describes itself.
+             try:
+-                representation = loads(
+-                    text_type(self._root._browser.get(url)))
++                url_get = self._root._browser.get(url)
++                if isinstance(url_get, binary_type):
++                    url_get = url_get.decode('utf-8')                
++                representation = loads(url_get)
+             except HTTPError as error:
+                 # There's no resource corresponding to the given ID.
+                 if error.response.status == 404:
+

Added: packages/lazr.restfulclient/trunk/debian/patches/series
===================================================================
--- packages/lazr.restfulclient/trunk/debian/patches/series	                        (rev 0)
+++ packages/lazr.restfulclient/trunk/debian/patches/series	2015-01-21 18:58:31 UTC (rev 31680)
@@ -0,0 +1 @@
+lp1403524.patch




More information about the Python-modules-commits mailing list