title: Python3 strange error with json.loads
body: <p>I'm using <a href="/questions/tagged/flask" class="post-tag" title="show questions tagged &#39;flask&#39;" rel="tag">flask</a> in a web application that uses service api generates JSON response. The following part of the function works fine and returns JSON text output:</p>
  
  <pre><code>def get_weather(query = 'london'):
      api_url = "http://api.openweathermap.org/data/2.5/weather?q={}&amp;units=metric&amp;appid=XXXXX****2a6eaf86760c"
      query = urllib.request.quote(query)
      url = api_url.format(query)
      response = urllib.request.urlopen(url)
      data = response.read()    
      return data
  </code></pre>
  
  <p>The output returned is:</p>
  
  <pre><code>{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"cmc stations","main":{"temp":12.95,"pressure":1030,"humidity":68,"temp_min":12.95,"temp_max":12.95,"sea_level":1039.93,"grnd_level":1030},"wind":{"speed":5.11,"deg":279.006},"clouds":{"all":76},"dt":1462290955,"sys":{"message":0.0048,"country":"GB","sunrise":1462249610,"sunset":1462303729},"id":2643743,"name":"London","cod":200}
  </code></pre>
  
  <p>This mean that <code>data</code> is a string, does not it?</p>
  
  <p><strong>However</strong>, commenting the <code>return data</code> and then adding the following two lines:</p>
  
  <pre><code>jsonData = json.loads(data)
  return jsonData
  </code></pre>
  
  <p>generates the following error:</p>
  
  <blockquote>
    <p>TypeError: the JSON object must be str, not 'bytes'</p>
  </blockquote>
  
  <p>What's wrong? <code>data</code>, <em>the JSON object</em>, previously returned as a string! I need to know where is the mistake?</p>