prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Update to_query_str to intelligently handle lists
  
  
  </issue>
  <code>
  [start of falcon/util.py]
  1 """Defines Falcon utility functions
  2 
  3 Copyright 2013 by Rackspace Hosting, Inc.
  4 
  5 Licensed under the Apache License, Version 2.0 (the "License");
  6 you may not use this file except in compliance with the License.
  7 You may obtain a copy of the License at
  8 
  9    http://www.apache.org/licenses/LICENSE-2.0
  10 
  11 Unless required by applicable law or agreed to in writing, software
  12 distributed under the License is distributed on an "AS IS" BASIS,
  13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 See the License for the specific language governing permissions and
  15 limitations under the License.
  16 
  17 """
  18 
  19 import datetime
  20 import six
  21 
  22 if six.PY3:  # pragma nocover
  23     from urllib.parse import quote as url_quote
  24 else:  # pragma nocover
  25     from urllib import quote as url_quote
  26 
  27 
  28 __all__ = ('dt_to_http', 'http_date_to_dt', 'to_query_str', 'percent_escape')
  29 
  30 
  31 def dt_to_http(dt):
  32     """Converts a datetime instance to an HTTP date string.
  33 
  34     Args:
  35         dt: A datetime object, assumed to be UTC
  36 
  37     Returns:
  38         An HTTP date string, e.g., "Tue, 15 Nov 1994 12:45:26 GMT". See
  39         also: http://goo.gl/R7So4
  40     """
  41 
  42     # Tue, 15 Nov 1994 12:45:26 GMT
  43     return dt.strftime('%a, %d %b %Y %H:%M:%S GMT')
  44 
  45 
  46 def http_date_to_dt(http_date):
  47     """Converts an HTTP date string to a datetime instance.
  48 
  49     Args:
  50         http_date: An HTTP date string, e.g., "Tue, 15 Nov 1994 12:45:26 GMT".
  51 
  52     Returns:
  53         A UTC datetime instance corresponding to the given HTTP date.
  54     """
  55 
  56     return datetime.datetime.strptime(
  57         http_date, '%a, %d %b %Y %H:%M:%S %Z')
  58 
  59 
  60 def to_query_str(params):
  61     """Converts a dict of params to afaln actual query string.
  62 
  63     Args:
  64         params: dict of simple key-value types, where key is a string and
  65             value is a string or something that can be converted into a
  66             string.
  67 
  68     Returns:
  69         A URI query string starting with '?', or and empty string if there
  70         are no params (the dict is empty).
  71     """
  72 
  73     if not params:
  74         return ''
  75 
  76     # PERF: This is faster than a list comprehension and join, mainly
  77     # because it allows us to inline the value transform.
  78     query_str = '?'
  79     for k, v in params.items():
  80         if v is True:
  81             v = 'true'
  82         elif v is False:
  83             v = 'false'
  84         else:
  85             v = str(v)
  86 
  87         query_str += k + '=' + v + '&'
  88 
  89     return query_str[:-1]
  90 
  91 
  92 def percent_escape(url):
  93     """Percent-escape reserved characters in the given url.
  94 
  95     Args:
  96         url: A full or relative URL.
  97 
  98     Returns:
  99         An escaped version of the URL, excluding '/', ',' and ':'
  100         characters. In Python 2, unicode URL strings will be first
  101         encoded to a UTF-8 byte string to work around a urllib
  102         bug.
  103     """
  104 
  105     # Convert the string so that urllib.quote does not complain
  106     # if it actually has Unicode chars in it.
  107     if not six.PY3 and isinstance(url, six.text_type):  # pragma nocover
  108         url = url.encode('utf-8')
  109 
  110     return url_quote(url, safe='/:,=?&-_')
  111
  [end of falcon/util.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/falcon/util.py b/falcon/util.py
  --- a/falcon/util.py
  +++ b/falcon/util.py
  @@ -63,7 +63,8 @@
       Args:
           params: dict of simple key-value types, where key is a string and
               value is a string or something that can be converted into a
  -            string.
  +            string. If value is a list, it will be converted to a comma-
  +            delimited string (e.g., thing=1,2,3)
   
       Returns:
           A URI query string starting with '?', or and empty string if there
  @@ -81,6 +82,8 @@
               v = 'true'
           elif v is False:
               v = 'false'
  +        elif isinstance(v, list):
  +            v = ','.join([str(i) for i in v])
           else:
               v = str(v)
  
verification_info: {"golden_diff": "diff --git a/falcon/util.py b/falcon/util.py\n--- a/falcon/util.py\n+++ b/falcon/util.py\n@@ -63,7 +63,8 @@\n     Args:\n         params: dict of simple key-value types, where key is a string and\n             value is a string or something that can be converted into a\n-            string.\n+            string. If value is a list, it will be converted to a comma-\n+            delimited string (e.g., thing=1,2,3)\n \n     Returns:\n         A URI query string starting with '?', or and empty string if there\n@@ -81,6 +82,8 @@\n             v = 'true'\n         elif v is False:\n             v = 'false'\n+        elif isinstance(v, list):\n+            v = ','.join([str(i) for i in v])\n         else:\n             v = str(v)\n", "issue": "Update to_query_str to intelligently handle lists\n\n", "before_files": [{"content": "\"\"\"Defines Falcon utility functions\n\nCopyright 2013 by Rackspace Hosting, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\"\"\"\n\nimport datetime\nimport six\n\nif six.PY3:  # pragma nocover\n    from urllib.parse import quote as url_quote\nelse:  # pragma nocover\n    from urllib import quote as url_quote\n\n\n__all__ = ('dt_to_http', 'http_date_to_dt', 'to_query_str', 'percent_escape')\n\n\ndef dt_to_http(dt):\n    \"\"\"Converts a datetime instance to an HTTP date string.\n\n    Args:\n        dt: A datetime object, assumed to be UTC\n\n    Returns:\n        An HTTP date string, e.g., \"Tue, 15 Nov 1994 12:45:26 GMT\". See\n        also: http://goo.gl/R7So4\n    \"\"\"\n\n    # Tue, 15 Nov 1994 12:45:26 GMT\n    return dt.strftime('%a, %d %b %Y %H:%M:%S GMT')\n\n\ndef http_date_to_dt(http_date):\n    \"\"\"Converts an HTTP date string to a datetime instance.\n\n    Args:\n        http_date: An HTTP date string, e.g., \"Tue, 15 Nov 1994 12:45:26 GMT\".\n\n    Returns:\n        A UTC datetime instance corresponding to the given HTTP date.\n    \"\"\"\n\n    return datetime.datetime.strptime(\n        http_date, '%a, %d %b %Y %H:%M:%S %Z')\n\n\ndef to_query_str(params):\n    \"\"\"Converts a dict of params to afaln actual query string.\n\n    Args:\n        params: dict of simple key-value types, where key is a string and\n            value is a string or something that can be converted into a\n            string.\n\n    Returns:\n        A URI query string starting with '?', or and empty string if there\n        are no params (the dict is empty).\n    \"\"\"\n\n    if not params:\n        return ''\n\n    # PERF: This is faster than a list comprehension and join, mainly\n    # because it allows us to inline the value transform.\n    query_str = '?'\n    for k, v in params.items():\n        if v is True:\n            v = 'true'\n        elif v is False:\n            v = 'false'\n        else:\n            v = str(v)\n\n        query_str += k + '=' + v + '&'\n\n    return query_str[:-1]\n\n\ndef percent_escape(url):\n    \"\"\"Percent-escape reserved characters in the given url.\n\n    Args:\n        url: A full or relative URL.\n\n    Returns:\n        An escaped version of the URL, excluding '/', ',' and ':'\n        characters. In Python 2, unicode URL strings will be first\n        encoded to a UTF-8 byte string to work around a urllib\n        bug.\n    \"\"\"\n\n    # Convert the string so that urllib.quote does not complain\n    # if it actually has Unicode chars in it.\n    if not six.PY3 and isinstance(url, six.text_type):  # pragma nocover\n        url = url.encode('utf-8')\n\n    return url_quote(url, safe='/:,=?&-_')\n", "path": "falcon/util.py"}]}