prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  CustomJsonEncoder drops currency information from Money instance
  Usually, we are using `settings.DEFAULT_CURRENCY` all over the place, however, there can be a bug, where `Money` is saved into `JSONField`, and `settings.DEFAULT_CURRENCY` changed meanwhile.
  
  
  
  </issue>
  <code>
  [start of saleor/core/utils/json_serializer.py]
  1 from django.core.serializers.json import (
  2     Deserializer as JsonDeserializer, DjangoJSONEncoder,
  3     Serializer as JsonSerializer)
  4 from prices import Money
  5 
  6 
  7 class Serializer(JsonSerializer):
  8     def _init_options(self):
  9         super()._init_options()
  10         self.json_kwargs['cls'] = CustomJsonEncoder
  11 
  12 
  13 class CustomJsonEncoder(DjangoJSONEncoder):
  14     def default(self, obj):
  15         if isinstance(obj, Money):
  16             return obj.amount
  17         return super().default(obj)
  18 
  19 
  20 Deserializer = JsonDeserializer
  21
  [end of saleor/core/utils/json_serializer.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/saleor/core/utils/json_serializer.py b/saleor/core/utils/json_serializer.py
  --- a/saleor/core/utils/json_serializer.py
  +++ b/saleor/core/utils/json_serializer.py
  @@ -1,8 +1,12 @@
  +import json
  +
  +from django.core.serializers.base import DeserializationError
   from django.core.serializers.json import (
  -    Deserializer as JsonDeserializer, DjangoJSONEncoder,
  -    Serializer as JsonSerializer)
  +    DjangoJSONEncoder, PythonDeserializer, Serializer as JsonSerializer)
   from prices import Money
   
  +MONEY_TYPE = 'Money'
  +
   
   class Serializer(JsonSerializer):
       def _init_options(self):
  @@ -13,8 +17,32 @@
   class CustomJsonEncoder(DjangoJSONEncoder):
       def default(self, obj):
           if isinstance(obj, Money):
  -            return obj.amount
  +            return {
  +                '_type': MONEY_TYPE, 'amount': obj.amount,
  +                'currency': obj.currency}
           return super().default(obj)
   
   
  -Deserializer = JsonDeserializer
  +def object_hook(obj):
  +    if '_type' in obj and obj['_type'] == MONEY_TYPE:
  +        return Money(obj['amount'], obj['currency'])
  +    return obj
  +
  +
  +def Deserializer(stream_or_string, **options):
  +    """Deserialize a stream or string of JSON data. This is a slightly modified
  +    copy of Django implementation with additional argument <object_hook> in
  +    json.loads"""
  +    if not isinstance(stream_or_string, (bytes, str)):
  +        stream_or_string = stream_or_string.read()
  +    if isinstance(stream_or_string, bytes):
  +        stream_or_string = stream_or_string.decode()
  +    try:
  +        objects = json.loads(stream_or_string, object_hook=object_hook)
  +        yield from PythonDeserializer(objects, **options)
  +    except Exception as exc:
  +        # ugly construction to overcome pylint's warning
  +        # "The except handler raises immediately"
  +        if isinstance(exc, (GeneratorExit, DeserializationError)):
  +            raise
  +        raise DeserializationError() from exc
  
verification_info: {"golden_diff": "diff --git a/saleor/core/utils/json_serializer.py b/saleor/core/utils/json_serializer.py\n--- a/saleor/core/utils/json_serializer.py\n+++ b/saleor/core/utils/json_serializer.py\n@@ -1,8 +1,12 @@\n+import json\n+\n+from django.core.serializers.base import DeserializationError\n from django.core.serializers.json import (\n-    Deserializer as JsonDeserializer, DjangoJSONEncoder,\n-    Serializer as JsonSerializer)\n+    DjangoJSONEncoder, PythonDeserializer, Serializer as JsonSerializer)\n from prices import Money\n \n+MONEY_TYPE = 'Money'\n+\n \n class Serializer(JsonSerializer):\n     def _init_options(self):\n@@ -13,8 +17,32 @@\n class CustomJsonEncoder(DjangoJSONEncoder):\n     def default(self, obj):\n         if isinstance(obj, Money):\n-            return obj.amount\n+            return {\n+                '_type': MONEY_TYPE, 'amount': obj.amount,\n+                'currency': obj.currency}\n         return super().default(obj)\n \n \n-Deserializer = JsonDeserializer\n+def object_hook(obj):\n+    if '_type' in obj and obj['_type'] == MONEY_TYPE:\n+        return Money(obj['amount'], obj['currency'])\n+    return obj\n+\n+\n+def Deserializer(stream_or_string, **options):\n+    \"\"\"Deserialize a stream or string of JSON data. This is a slightly modified\n+    copy of Django implementation with additional argument <object_hook> in\n+    json.loads\"\"\"\n+    if not isinstance(stream_or_string, (bytes, str)):\n+        stream_or_string = stream_or_string.read()\n+    if isinstance(stream_or_string, bytes):\n+        stream_or_string = stream_or_string.decode()\n+    try:\n+        objects = json.loads(stream_or_string, object_hook=object_hook)\n+        yield from PythonDeserializer(objects, **options)\n+    except Exception as exc:\n+        # ugly construction to overcome pylint's warning\n+        # \"The except handler raises immediately\"\n+        if isinstance(exc, (GeneratorExit, DeserializationError)):\n+            raise\n+        raise DeserializationError() from exc\n", "issue": "CustomJsonEncoder drops currency information from Money instance\nUsually, we are using `settings.DEFAULT_CURRENCY` all over the place, however, there can be a bug, where `Money` is saved into `JSONField`, and `settings.DEFAULT_CURRENCY` changed meanwhile.\r\n\r\n\n", "before_files": [{"content": "from django.core.serializers.json import (\n    Deserializer as JsonDeserializer, DjangoJSONEncoder,\n    Serializer as JsonSerializer)\nfrom prices import Money\n\n\nclass Serializer(JsonSerializer):\n    def _init_options(self):\n        super()._init_options()\n        self.json_kwargs['cls'] = CustomJsonEncoder\n\n\nclass CustomJsonEncoder(DjangoJSONEncoder):\n    def default(self, obj):\n        if isinstance(obj, Money):\n            return obj.amount\n        return super().default(obj)\n\n\nDeserializer = JsonDeserializer\n", "path": "saleor/core/utils/json_serializer.py"}]}