prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  raises_unsupported_algorithm gives very unhelpful errors
  When the error tag is wrong you get errors along the lines of `assert <object object at 0xf0000000> is not <object object as 0xb0000000>`. This is not very helpful, it's not even particularly obvious that the error tag is actually what's wrong until you go and read the code.
  
  Should probably generate a useful error message or somehow give the tag objects a more useful `repr` output.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cryptography/exceptions.py`
  Content:
  ```
  1 # This file is dual licensed under the terms of the Apache License, Version
  2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3 # for complete details.
  4 
  5 from __future__ import absolute_import, division, print_function
  6 
  7 
  8 class _Reasons(object):
  9     BACKEND_MISSING_INTERFACE = object()
  10     UNSUPPORTED_HASH = object()
  11     UNSUPPORTED_CIPHER = object()
  12     UNSUPPORTED_PADDING = object()
  13     UNSUPPORTED_MGF = object()
  14     UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object()
  15     UNSUPPORTED_ELLIPTIC_CURVE = object()
  16     UNSUPPORTED_SERIALIZATION = object()
  17     UNSUPPORTED_X509 = object()
  18 
  19 
  20 class UnsupportedAlgorithm(Exception):
  21     def __init__(self, message, reason=None):
  22         super(UnsupportedAlgorithm, self).__init__(message)
  23         self._reason = reason
  24 
  25 
  26 class AlreadyFinalized(Exception):
  27     pass
  28 
  29 
  30 class AlreadyUpdated(Exception):
  31     pass
  32 
  33 
  34 class NotYetFinalized(Exception):
  35     pass
  36 
  37 
  38 class InvalidTag(Exception):
  39     pass
  40 
  41 
  42 class InvalidSignature(Exception):
  43     pass
  44 
  45 
  46 class InternalError(Exception):
  47     pass
  48 
  49 
  50 class InvalidKey(Exception):
  51     pass
  52 
  53 
  54 class InvalidToken(Exception):
  55     pass
  56
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py
  --- a/src/cryptography/exceptions.py
  +++ b/src/cryptography/exceptions.py
  @@ -4,17 +4,19 @@
   
   from __future__ import absolute_import, division, print_function
   
  -
  -class _Reasons(object):
  -    BACKEND_MISSING_INTERFACE = object()
  -    UNSUPPORTED_HASH = object()
  -    UNSUPPORTED_CIPHER = object()
  -    UNSUPPORTED_PADDING = object()
  -    UNSUPPORTED_MGF = object()
  -    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object()
  -    UNSUPPORTED_ELLIPTIC_CURVE = object()
  -    UNSUPPORTED_SERIALIZATION = object()
  -    UNSUPPORTED_X509 = object()
  +from enum import Enum
  +
  +
  +class _Reasons(Enum):
  +    BACKEND_MISSING_INTERFACE = 0
  +    UNSUPPORTED_HASH = 1
  +    UNSUPPORTED_CIPHER = 2
  +    UNSUPPORTED_PADDING = 3
  +    UNSUPPORTED_MGF = 4
  +    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5
  +    UNSUPPORTED_ELLIPTIC_CURVE = 6
  +    UNSUPPORTED_SERIALIZATION = 7
  +    UNSUPPORTED_X509 = 8
   
   
   class UnsupportedAlgorithm(Exception):
  
verification_info: {"golden_diff": "diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py\n--- a/src/cryptography/exceptions.py\n+++ b/src/cryptography/exceptions.py\n@@ -4,17 +4,19 @@\n \n from __future__ import absolute_import, division, print_function\n \n-\n-class _Reasons(object):\n-    BACKEND_MISSING_INTERFACE = object()\n-    UNSUPPORTED_HASH = object()\n-    UNSUPPORTED_CIPHER = object()\n-    UNSUPPORTED_PADDING = object()\n-    UNSUPPORTED_MGF = object()\n-    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object()\n-    UNSUPPORTED_ELLIPTIC_CURVE = object()\n-    UNSUPPORTED_SERIALIZATION = object()\n-    UNSUPPORTED_X509 = object()\n+from enum import Enum\n+\n+\n+class _Reasons(Enum):\n+    BACKEND_MISSING_INTERFACE = 0\n+    UNSUPPORTED_HASH = 1\n+    UNSUPPORTED_CIPHER = 2\n+    UNSUPPORTED_PADDING = 3\n+    UNSUPPORTED_MGF = 4\n+    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5\n+    UNSUPPORTED_ELLIPTIC_CURVE = 6\n+    UNSUPPORTED_SERIALIZATION = 7\n+    UNSUPPORTED_X509 = 8\n \n \n class UnsupportedAlgorithm(Exception):\n", "issue": "raises_unsupported_algorithm gives very unhelpful errors\nWhen the error tag is wrong you get errors along the lines of `assert <object object at 0xf0000000> is not <object object as 0xb0000000>`. This is not very helpful, it's not even particularly obvious that the error tag is actually what's wrong until you go and read the code.\n\nShould probably generate a useful error message or somehow give the tag objects a more useful `repr` output.\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\n\nclass _Reasons(object):\n    BACKEND_MISSING_INTERFACE = object()\n    UNSUPPORTED_HASH = object()\n    UNSUPPORTED_CIPHER = object()\n    UNSUPPORTED_PADDING = object()\n    UNSUPPORTED_MGF = object()\n    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object()\n    UNSUPPORTED_ELLIPTIC_CURVE = object()\n    UNSUPPORTED_SERIALIZATION = object()\n    UNSUPPORTED_X509 = object()\n\n\nclass UnsupportedAlgorithm(Exception):\n    def __init__(self, message, reason=None):\n        super(UnsupportedAlgorithm, self).__init__(message)\n        self._reason = reason\n\n\nclass AlreadyFinalized(Exception):\n    pass\n\n\nclass AlreadyUpdated(Exception):\n    pass\n\n\nclass NotYetFinalized(Exception):\n    pass\n\n\nclass InvalidTag(Exception):\n    pass\n\n\nclass InvalidSignature(Exception):\n    pass\n\n\nclass InternalError(Exception):\n    pass\n\n\nclass InvalidKey(Exception):\n    pass\n\n\nclass InvalidToken(Exception):\n    pass\n", "path": "src/cryptography/exceptions.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nfrom enum import Enum\n\n\nclass _Reasons(Enum):\n    BACKEND_MISSING_INTERFACE = 0\n    UNSUPPORTED_HASH = 1\n    UNSUPPORTED_CIPHER = 2\n    UNSUPPORTED_PADDING = 3\n    UNSUPPORTED_MGF = 4\n    UNSUPPORTED_PUBLIC_KEY_ALGORITHM = 5\n    UNSUPPORTED_ELLIPTIC_CURVE = 6\n    UNSUPPORTED_SERIALIZATION = 7\n    UNSUPPORTED_X509 = 8\n\n\nclass UnsupportedAlgorithm(Exception):\n    def __init__(self, message, reason=None):\n        super(UnsupportedAlgorithm, self).__init__(message)\n        self._reason = reason\n\n\nclass AlreadyFinalized(Exception):\n    pass\n\n\nclass AlreadyUpdated(Exception):\n    pass\n\n\nclass NotYetFinalized(Exception):\n    pass\n\n\nclass InvalidTag(Exception):\n    pass\n\n\nclass InvalidSignature(Exception):\n    pass\n\n\nclass InternalError(Exception):\n    pass\n\n\nclass InvalidKey(Exception):\n    pass\n\n\nclass InvalidToken(Exception):\n    pass\n", "path": "src/cryptography/exceptions.py"}]}