prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Kombu compression "encodes" the body ?
  At https://github.com/ask/kombu/blob/master/kombu/compression.py#L61, we see:
  
  ```
  return encoder(body.encode("utf-8")), content_type
  ```
  
  Same for decoding. What gives? It crashes with msgpack (which can't be encoded). Is there any reason for that ?
  
  
  </issue>
  <code>
  [start of kombu/compression.py]
  1 """
  2 kombu.compression
  3 =================
  4 
  5 Compression utilities.
  6 
  7 :copyright: (c) 2009 - 2012 by Ask Solem.
  8 :license: BSD, see LICENSE for more details.
  9 
  10 """
  11 from __future__ import absolute_import
  12 
  13 import zlib
  14 
  15 _aliases = {}
  16 _encoders = {}
  17 _decoders = {}
  18 
  19 __all__ = ["register", "encoders", "get_encoder",
  20            "get_decoder", "compress", "decompress"]
  21 
  22 
  23 def register(encoder, decoder, content_type, aliases=[]):
  24     """Register new compression method.
  25 
  26     :param encoder: Function used to compress text.
  27     :param decoder: Function used to decompress previously compressed text.
  28     :param content_type: The mime type this compression method identifies as.
  29     :param aliases: A list of names to associate with this compression method.
  30 
  31     """
  32     _encoders[content_type] = encoder
  33     _decoders[content_type] = decoder
  34     _aliases.update((alias, content_type) for alias in aliases)
  35 
  36 
  37 def encoders():
  38     """Returns a list of available compression methods."""
  39     return _encoders.keys()
  40 
  41 
  42 def get_encoder(t):
  43     """Get encoder by alias name."""
  44     t = _aliases.get(t, t)
  45     return _encoders[t], t
  46 
  47 
  48 def get_decoder(t):
  49     """Get decoder by alias name."""
  50     return _decoders[_aliases.get(t, t)]
  51 
  52 
  53 def compress(body, content_type):
  54     """Compress text.
  55 
  56     :param body: The text to compress.
  57     :param content_type: mime-type of compression method to use.
  58 
  59     """
  60     encoder, content_type = get_encoder(content_type)
  61     return encoder(body.encode("utf-8")), content_type
  62 
  63 
  64 def decompress(body, content_type):
  65     """Decompress compressed text.
  66 
  67     :param body: Previously compressed text to uncompress.
  68     :param content_type: mime-type of compression method used.
  69 
  70     """
  71     return get_decoder(content_type)(body).decode("utf-8")
  72 
  73 
  74 register(zlib.compress,
  75          zlib.decompress,
  76          "application/x-gzip", aliases=["gzip", "zlib"])
  77 try:
  78     import bz2
  79 except ImportError:
  80     pass  # Jython?
  81 else:
  82     register(bz2.compress,
  83              bz2.decompress,
  84              "application/x-bz2", aliases=["bzip2", "bzip"])
  85
  [end of kombu/compression.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/kombu/compression.py b/kombu/compression.py
  --- a/kombu/compression.py
  +++ b/kombu/compression.py
  @@ -10,6 +10,8 @@
   """
   from __future__ import absolute_import
   
  +from kombu.utils.encoding import ensure_bytes, bytes_to_str
  +
   import zlib
   
   _aliases = {}
  @@ -58,7 +60,7 @@
   
       """
       encoder, content_type = get_encoder(content_type)
  -    return encoder(body.encode("utf-8")), content_type
  +    return encoder(ensure_bytes(body)), content_type
   
   
   def decompress(body, content_type):
  @@ -68,7 +70,7 @@
       :param content_type: mime-type of compression method used.
   
       """
  -    return get_decoder(content_type)(body).decode("utf-8")
  +    return bytes_to_str(get_decoder(content_type)(body))
   
   
   register(zlib.compress,
  
verification_info: {"golden_diff": "diff --git a/kombu/compression.py b/kombu/compression.py\n--- a/kombu/compression.py\n+++ b/kombu/compression.py\n@@ -10,6 +10,8 @@\n \"\"\"\n from __future__ import absolute_import\n \n+from kombu.utils.encoding import ensure_bytes, bytes_to_str\n+\n import zlib\n \n _aliases = {}\n@@ -58,7 +60,7 @@\n \n     \"\"\"\n     encoder, content_type = get_encoder(content_type)\n-    return encoder(body.encode(\"utf-8\")), content_type\n+    return encoder(ensure_bytes(body)), content_type\n \n \n def decompress(body, content_type):\n@@ -68,7 +70,7 @@\n     :param content_type: mime-type of compression method used.\n \n     \"\"\"\n-    return get_decoder(content_type)(body).decode(\"utf-8\")\n+    return bytes_to_str(get_decoder(content_type)(body))\n \n \n register(zlib.compress,\n", "issue": "Kombu compression \"encodes\" the body ?\nAt https://github.com/ask/kombu/blob/master/kombu/compression.py#L61, we see:\n\n```\nreturn encoder(body.encode(\"utf-8\")), content_type\n```\n\nSame for decoding. What gives? It crashes with msgpack (which can't be encoded). Is there any reason for that ?\n\n", "before_files": [{"content": "\"\"\"\nkombu.compression\n=================\n\nCompression utilities.\n\n:copyright: (c) 2009 - 2012 by Ask Solem.\n:license: BSD, see LICENSE for more details.\n\n\"\"\"\nfrom __future__ import absolute_import\n\nimport zlib\n\n_aliases = {}\n_encoders = {}\n_decoders = {}\n\n__all__ = [\"register\", \"encoders\", \"get_encoder\",\n           \"get_decoder\", \"compress\", \"decompress\"]\n\n\ndef register(encoder, decoder, content_type, aliases=[]):\n    \"\"\"Register new compression method.\n\n    :param encoder: Function used to compress text.\n    :param decoder: Function used to decompress previously compressed text.\n    :param content_type: The mime type this compression method identifies as.\n    :param aliases: A list of names to associate with this compression method.\n\n    \"\"\"\n    _encoders[content_type] = encoder\n    _decoders[content_type] = decoder\n    _aliases.update((alias, content_type) for alias in aliases)\n\n\ndef encoders():\n    \"\"\"Returns a list of available compression methods.\"\"\"\n    return _encoders.keys()\n\n\ndef get_encoder(t):\n    \"\"\"Get encoder by alias name.\"\"\"\n    t = _aliases.get(t, t)\n    return _encoders[t], t\n\n\ndef get_decoder(t):\n    \"\"\"Get decoder by alias name.\"\"\"\n    return _decoders[_aliases.get(t, t)]\n\n\ndef compress(body, content_type):\n    \"\"\"Compress text.\n\n    :param body: The text to compress.\n    :param content_type: mime-type of compression method to use.\n\n    \"\"\"\n    encoder, content_type = get_encoder(content_type)\n    return encoder(body.encode(\"utf-8\")), content_type\n\n\ndef decompress(body, content_type):\n    \"\"\"Decompress compressed text.\n\n    :param body: Previously compressed text to uncompress.\n    :param content_type: mime-type of compression method used.\n\n    \"\"\"\n    return get_decoder(content_type)(body).decode(\"utf-8\")\n\n\nregister(zlib.compress,\n         zlib.decompress,\n         \"application/x-gzip\", aliases=[\"gzip\", \"zlib\"])\ntry:\n    import bz2\nexcept ImportError:\n    pass  # Jython?\nelse:\n    register(bz2.compress,\n             bz2.decompress,\n             \"application/x-bz2\", aliases=[\"bzip2\", \"bzip\"])\n", "path": "kombu/compression.py"}]}