prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  trio.Cancelled missing readable str()
  Trying to print a trio.Cancelled exception e.g. with `f'{exc}'` yields an empty string.  I usually resort to `type(exc)` when I need to see what's going on.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `trio/_core/_exceptions.py`
  Content:
  ```
  1 import attr
  2 
  3 
  4 class TrioInternalError(Exception):
  5     """Raised by :func:`run` if we encounter a bug in trio, or (possibly) a
  6     misuse of one of the low-level :mod:`trio.hazmat` APIs.
  7 
  8     This should never happen! If you get this error, please file a bug.
  9 
  10     Unfortunately, if you get this error it also means that all bets are off –
  11     trio doesn't know what is going on and its normal invariants may be void.
  12     (For example, we might have "lost track" of a task. Or lost track of all
  13     tasks.) Again, though, this shouldn't happen.
  14 
  15     """
  16     pass
  17 
  18 
  19 class RunFinishedError(RuntimeError):
  20     """Raised by ``run_in_trio_thread`` and similar functions if the
  21     corresponding call to :func:`trio.run` has already finished.
  22 
  23     """
  24     pass
  25 
  26 
  27 class WouldBlock(Exception):
  28     """Raised by ``X_nowait`` functions if ``X`` would block.
  29 
  30     """
  31     pass
  32 
  33 
  34 class Cancelled(BaseException):
  35     """Raised by blocking calls if the surrounding scope has been cancelled.
  36 
  37     You should let this exception propagate, to be caught by the relevant
  38     cancel scope. To remind you of this, it inherits from :exc:`BaseException`
  39     instead of :exc:`Exception`, just like :exc:`KeyboardInterrupt` and
  40     :exc:`SystemExit` do. This means that if you write something like::
  41 
  42        try:
  43            ...
  44        except Exception:
  45            ...
  46 
  47     then this *won't* catch a :exc:`Cancelled` exception.
  48 
  49     You cannot raise :exc:`Cancelled` yourself. Attempting to do so
  50     will produce a :exc:`RuntimeError`. Use :meth:`cancel_scope.cancel()
  51     <trio.CancelScope.cancel>` instead.
  52 
  53     .. note::
  54 
  55        In the US it's also common to see this word spelled "canceled", with
  56        only one "l". This is a `recent
  57        <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=5&smoothing=3&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__
  58        and `US-specific
  59        <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=18&smoothing=3&share=&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__
  60        innovation, and even in the US both forms are still commonly used. So
  61        for consistency with the rest of the world and with "cancellation"
  62        (which always has two "l"s), trio uses the two "l" spelling
  63        everywhere.
  64 
  65     """
  66     __marker = object()
  67 
  68     def __init__(self, _marker=None):
  69         if _marker is not self.__marker:
  70             raise RuntimeError(
  71                 'Cancelled should not be raised directly. Use the cancel() '
  72                 'method on your cancel scope.'
  73             )
  74         super().__init__()
  75 
  76     @classmethod
  77     def _init(cls):
  78         """A private constructor so that a user-created instance of Cancelled
  79         can raise an appropriate error. see `issue #342
  80         <https://github.com/python-trio/trio/issues/342>`__.
  81         """
  82         return cls(_marker=cls.__marker)
  83 
  84 
  85 class BusyResourceError(Exception):
  86     """Raised when a task attempts to use a resource that some other task is
  87     already using, and this would lead to bugs and nonsense.
  88 
  89     For example, if two tasks try to send data through the same socket at the
  90     same time, trio will raise :class:`BusyResourceError` instead of letting
  91     the data get scrambled.
  92 
  93     """
  94 
  95 
  96 class ClosedResourceError(Exception):
  97     """Raised when attempting to use a resource after it has been closed.
  98 
  99     Note that "closed" here means that *your* code closed the resource,
  100     generally by calling a method with a name like ``close`` or ``aclose``, or
  101     by exiting a context manager. If a problem arises elsewhere – for example,
  102     because of a network failure, or because a remote peer closed their end of
  103     a connection – then that should be indicated by a different exception
  104     class, like :exc:`BrokenResourceError` or an :exc:`OSError` subclass.
  105 
  106     """
  107 
  108 
  109 class BrokenResourceError(Exception):
  110     """Raised when an attempt to use a resource fails due to external
  111     circumstances.
  112 
  113     For example, you might get this if you try to send data on a stream where
  114     the remote side has already closed the connection.
  115 
  116     You *don't* get this error if *you* closed the resource – in that case you
  117     get :class:`ClosedResourceError`.
  118 
  119     This exception's ``__cause__`` attribute will often contain more
  120     information about the underlying error.
  121 
  122     """
  123 
  124 
  125 class EndOfChannel(Exception):
  126     """Raised when trying to receive from a :class:`trio.abc.ReceiveChannel`
  127     that has no more data to receive.
  128 
  129     This is analogous to an "end-of-file" condition, but for channels.
  130 
  131     """
  132
  ```
  --- 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/trio/_core/_exceptions.py b/trio/_core/_exceptions.py
  --- a/trio/_core/_exceptions.py
  +++ b/trio/_core/_exceptions.py
  @@ -73,6 +73,9 @@
               )
           super().__init__()
   
  +    def __str__(self):
  +        return "Cancelled"
  +
       @classmethod
       def _init(cls):
           """A private constructor so that a user-created instance of Cancelled
  
verification_info: {"golden_diff": "diff --git a/trio/_core/_exceptions.py b/trio/_core/_exceptions.py\n--- a/trio/_core/_exceptions.py\n+++ b/trio/_core/_exceptions.py\n@@ -73,6 +73,9 @@\n             )\n         super().__init__()\n \n+    def __str__(self):\n+        return \"Cancelled\"\n+\n     @classmethod\n     def _init(cls):\n         \"\"\"A private constructor so that a user-created instance of Cancelled\n", "issue": "trio.Cancelled missing readable str()\nTrying to print a trio.Cancelled exception e.g. with `f'{exc}'` yields an empty string.  I usually resort to `type(exc)` when I need to see what's going on.\n", "before_files": [{"content": "import attr\n\n\nclass TrioInternalError(Exception):\n    \"\"\"Raised by :func:`run` if we encounter a bug in trio, or (possibly) a\n    misuse of one of the low-level :mod:`trio.hazmat` APIs.\n\n    This should never happen! If you get this error, please file a bug.\n\n    Unfortunately, if you get this error it also means that all bets are off \u2013\n    trio doesn't know what is going on and its normal invariants may be void.\n    (For example, we might have \"lost track\" of a task. Or lost track of all\n    tasks.) Again, though, this shouldn't happen.\n\n    \"\"\"\n    pass\n\n\nclass RunFinishedError(RuntimeError):\n    \"\"\"Raised by ``run_in_trio_thread`` and similar functions if the\n    corresponding call to :func:`trio.run` has already finished.\n\n    \"\"\"\n    pass\n\n\nclass WouldBlock(Exception):\n    \"\"\"Raised by ``X_nowait`` functions if ``X`` would block.\n\n    \"\"\"\n    pass\n\n\nclass Cancelled(BaseException):\n    \"\"\"Raised by blocking calls if the surrounding scope has been cancelled.\n\n    You should let this exception propagate, to be caught by the relevant\n    cancel scope. To remind you of this, it inherits from :exc:`BaseException`\n    instead of :exc:`Exception`, just like :exc:`KeyboardInterrupt` and\n    :exc:`SystemExit` do. This means that if you write something like::\n\n       try:\n           ...\n       except Exception:\n           ...\n\n    then this *won't* catch a :exc:`Cancelled` exception.\n\n    You cannot raise :exc:`Cancelled` yourself. Attempting to do so\n    will produce a :exc:`RuntimeError`. Use :meth:`cancel_scope.cancel()\n    <trio.CancelScope.cancel>` instead.\n\n    .. note::\n\n       In the US it's also common to see this word spelled \"canceled\", with\n       only one \"l\". This is a `recent\n       <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=5&smoothing=3&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__\n       and `US-specific\n       <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=18&smoothing=3&share=&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__\n       innovation, and even in the US both forms are still commonly used. So\n       for consistency with the rest of the world and with \"cancellation\"\n       (which always has two \"l\"s), trio uses the two \"l\" spelling\n       everywhere.\n\n    \"\"\"\n    __marker = object()\n\n    def __init__(self, _marker=None):\n        if _marker is not self.__marker:\n            raise RuntimeError(\n                'Cancelled should not be raised directly. Use the cancel() '\n                'method on your cancel scope.'\n            )\n        super().__init__()\n\n    @classmethod\n    def _init(cls):\n        \"\"\"A private constructor so that a user-created instance of Cancelled\n        can raise an appropriate error. see `issue #342\n        <https://github.com/python-trio/trio/issues/342>`__.\n        \"\"\"\n        return cls(_marker=cls.__marker)\n\n\nclass BusyResourceError(Exception):\n    \"\"\"Raised when a task attempts to use a resource that some other task is\n    already using, and this would lead to bugs and nonsense.\n\n    For example, if two tasks try to send data through the same socket at the\n    same time, trio will raise :class:`BusyResourceError` instead of letting\n    the data get scrambled.\n\n    \"\"\"\n\n\nclass ClosedResourceError(Exception):\n    \"\"\"Raised when attempting to use a resource after it has been closed.\n\n    Note that \"closed\" here means that *your* code closed the resource,\n    generally by calling a method with a name like ``close`` or ``aclose``, or\n    by exiting a context manager. If a problem arises elsewhere \u2013 for example,\n    because of a network failure, or because a remote peer closed their end of\n    a connection \u2013 then that should be indicated by a different exception\n    class, like :exc:`BrokenResourceError` or an :exc:`OSError` subclass.\n\n    \"\"\"\n\n\nclass BrokenResourceError(Exception):\n    \"\"\"Raised when an attempt to use a resource fails due to external\n    circumstances.\n\n    For example, you might get this if you try to send data on a stream where\n    the remote side has already closed the connection.\n\n    You *don't* get this error if *you* closed the resource \u2013 in that case you\n    get :class:`ClosedResourceError`.\n\n    This exception's ``__cause__`` attribute will often contain more\n    information about the underlying error.\n\n    \"\"\"\n\n\nclass EndOfChannel(Exception):\n    \"\"\"Raised when trying to receive from a :class:`trio.abc.ReceiveChannel`\n    that has no more data to receive.\n\n    This is analogous to an \"end-of-file\" condition, but for channels.\n\n    \"\"\"\n", "path": "trio/_core/_exceptions.py"}], "after_files": [{"content": "import attr\n\n\nclass TrioInternalError(Exception):\n    \"\"\"Raised by :func:`run` if we encounter a bug in trio, or (possibly) a\n    misuse of one of the low-level :mod:`trio.hazmat` APIs.\n\n    This should never happen! If you get this error, please file a bug.\n\n    Unfortunately, if you get this error it also means that all bets are off \u2013\n    trio doesn't know what is going on and its normal invariants may be void.\n    (For example, we might have \"lost track\" of a task. Or lost track of all\n    tasks.) Again, though, this shouldn't happen.\n\n    \"\"\"\n    pass\n\n\nclass RunFinishedError(RuntimeError):\n    \"\"\"Raised by ``run_in_trio_thread`` and similar functions if the\n    corresponding call to :func:`trio.run` has already finished.\n\n    \"\"\"\n    pass\n\n\nclass WouldBlock(Exception):\n    \"\"\"Raised by ``X_nowait`` functions if ``X`` would block.\n\n    \"\"\"\n    pass\n\n\nclass Cancelled(BaseException):\n    \"\"\"Raised by blocking calls if the surrounding scope has been cancelled.\n\n    You should let this exception propagate, to be caught by the relevant\n    cancel scope. To remind you of this, it inherits from :exc:`BaseException`\n    instead of :exc:`Exception`, just like :exc:`KeyboardInterrupt` and\n    :exc:`SystemExit` do. This means that if you write something like::\n\n       try:\n           ...\n       except Exception:\n           ...\n\n    then this *won't* catch a :exc:`Cancelled` exception.\n\n    You cannot raise :exc:`Cancelled` yourself. Attempting to do so\n    will produce a :exc:`RuntimeError`. Use :meth:`cancel_scope.cancel()\n    <trio.CancelScope.cancel>` instead.\n\n    .. note::\n\n       In the US it's also common to see this word spelled \"canceled\", with\n       only one \"l\". This is a `recent\n       <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=5&smoothing=3&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__\n       and `US-specific\n       <https://books.google.com/ngrams/graph?content=canceled%2Ccancelled&year_start=1800&year_end=2000&corpus=18&smoothing=3&share=&direct_url=t1%3B%2Ccanceled%3B%2Cc0%3B.t1%3B%2Ccancelled%3B%2Cc0>`__\n       innovation, and even in the US both forms are still commonly used. So\n       for consistency with the rest of the world and with \"cancellation\"\n       (which always has two \"l\"s), trio uses the two \"l\" spelling\n       everywhere.\n\n    \"\"\"\n    __marker = object()\n\n    def __init__(self, _marker=None):\n        if _marker is not self.__marker:\n            raise RuntimeError(\n                'Cancelled should not be raised directly. Use the cancel() '\n                'method on your cancel scope.'\n            )\n        super().__init__()\n\n    def __str__(self):\n        return \"Cancelled\"\n\n    @classmethod\n    def _init(cls):\n        \"\"\"A private constructor so that a user-created instance of Cancelled\n        can raise an appropriate error. see `issue #342\n        <https://github.com/python-trio/trio/issues/342>`__.\n        \"\"\"\n        return cls(_marker=cls.__marker)\n\n\nclass BusyResourceError(Exception):\n    \"\"\"Raised when a task attempts to use a resource that some other task is\n    already using, and this would lead to bugs and nonsense.\n\n    For example, if two tasks try to send data through the same socket at the\n    same time, trio will raise :class:`BusyResourceError` instead of letting\n    the data get scrambled.\n\n    \"\"\"\n\n\nclass ClosedResourceError(Exception):\n    \"\"\"Raised when attempting to use a resource after it has been closed.\n\n    Note that \"closed\" here means that *your* code closed the resource,\n    generally by calling a method with a name like ``close`` or ``aclose``, or\n    by exiting a context manager. If a problem arises elsewhere \u2013 for example,\n    because of a network failure, or because a remote peer closed their end of\n    a connection \u2013 then that should be indicated by a different exception\n    class, like :exc:`BrokenResourceError` or an :exc:`OSError` subclass.\n\n    \"\"\"\n\n\nclass BrokenResourceError(Exception):\n    \"\"\"Raised when an attempt to use a resource fails due to external\n    circumstances.\n\n    For example, you might get this if you try to send data on a stream where\n    the remote side has already closed the connection.\n\n    You *don't* get this error if *you* closed the resource \u2013 in that case you\n    get :class:`ClosedResourceError`.\n\n    This exception's ``__cause__`` attribute will often contain more\n    information about the underlying error.\n\n    \"\"\"\n\n\nclass EndOfChannel(Exception):\n    \"\"\"Raised when trying to receive from a :class:`trio.abc.ReceiveChannel`\n    that has no more data to receive.\n\n    This is analogous to an \"end-of-file\" condition, but for channels.\n\n    \"\"\"\n", "path": "trio/_core/_exceptions.py"}]}