prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Avoid encode/decode in chat.py for better readablity
  As discussed in [this comment](https://github.com/twisted/twisted/pull/12070#discussion_r1442784443), it's better to use byte concat as mentioned in order of better readability in [docs/core/howto/listings/servers/chat.py:35](https://github.com/twisted/twisted/pull/12070/files/c59c93ec644a17e0f3a1752ca9ceca31a27a9f5e#diff-0923ff3db530a2e5d28ea8cc2b3a8f91f399792786772c541bf9edf7a0c50126)
  ```python
  message = b'<' + self.name + b'> ' + message
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docs/core/howto/listings/servers/chat.py`
  Content:
  ```
  1 from twisted.internet import reactor
  2 from twisted.internet.protocol import Factory
  3 from twisted.protocols.basic import LineReceiver
  4 
  5 
  6 class Chat(LineReceiver):
  7     def __init__(self, users):
  8         self.users = users
  9         self.name = None
  10         self.state = "GETNAME"
  11 
  12     def connectionMade(self):
  13         self.sendLine(b"What's your name?")
  14 
  15     def connectionLost(self, reason):
  16         if self.name in self.users:
  17             del self.users[self.name]
  18 
  19     def lineReceived(self, line):
  20         if self.state == "GETNAME":
  21             self.handle_GETNAME(line)
  22         else:
  23             self.handle_CHAT(line)
  24 
  25     def handle_GETNAME(self, name):
  26         if name in self.users:
  27             self.sendLine(b"Name taken, please choose another.")
  28             return
  29         self.sendLine(f"Welcome, {name.decode('utf-8')}!".encode("utf-8"))
  30         self.name = name
  31         self.users[name] = self
  32         self.state = "CHAT"
  33 
  34     def handle_CHAT(self, message):
  35         message = f"<{self.name.decode('utf-8')}> {message.decode('utf-8')}".encode(
  36             "utf-8"
  37         )
  38         for name, protocol in self.users.items():
  39             if protocol != self:
  40                 protocol.sendLine(message)
  41 
  42 
  43 class ChatFactory(Factory):
  44     def __init__(self):
  45         self.users = {}  # maps user names to Chat instances
  46 
  47     def buildProtocol(self, addr):
  48         return Chat(self.users)
  49 
  50 
  51 reactor.listenTCP(8123, ChatFactory())
  52 reactor.run()
  53
  ```
  --- 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/docs/core/howto/listings/servers/chat.py b/docs/core/howto/listings/servers/chat.py
  --- a/docs/core/howto/listings/servers/chat.py
  +++ b/docs/core/howto/listings/servers/chat.py
  @@ -32,9 +32,7 @@
           self.state = "CHAT"
   
       def handle_CHAT(self, message):
  -        message = f"<{self.name.decode('utf-8')}> {message.decode('utf-8')}".encode(
  -            "utf-8"
  -        )
  +        message = b"<" + self.name + b"> " + message
           for name, protocol in self.users.items():
               if protocol != self:
                   protocol.sendLine(message)
  
verification_info: {"golden_diff": "diff --git a/docs/core/howto/listings/servers/chat.py b/docs/core/howto/listings/servers/chat.py\n--- a/docs/core/howto/listings/servers/chat.py\n+++ b/docs/core/howto/listings/servers/chat.py\n@@ -32,9 +32,7 @@\n         self.state = \"CHAT\"\n \n     def handle_CHAT(self, message):\n-        message = f\"<{self.name.decode('utf-8')}> {message.decode('utf-8')}\".encode(\n-            \"utf-8\"\n-        )\n+        message = b\"<\" + self.name + b\"> \" + message\n         for name, protocol in self.users.items():\n             if protocol != self:\n                 protocol.sendLine(message)\n", "issue": "Avoid encode/decode in chat.py for better readablity\nAs discussed in [this comment](https://github.com/twisted/twisted/pull/12070#discussion_r1442784443), it's better to use byte concat as mentioned in order of better readability in [docs/core/howto/listings/servers/chat.py:35](https://github.com/twisted/twisted/pull/12070/files/c59c93ec644a17e0f3a1752ca9ceca31a27a9f5e#diff-0923ff3db530a2e5d28ea8cc2b3a8f91f399792786772c541bf9edf7a0c50126)\r\n```python\r\nmessage = b'<' + self.name + b'> ' + message\r\n```\n", "before_files": [{"content": "from twisted.internet import reactor\nfrom twisted.internet.protocol import Factory\nfrom twisted.protocols.basic import LineReceiver\n\n\nclass Chat(LineReceiver):\n    def __init__(self, users):\n        self.users = users\n        self.name = None\n        self.state = \"GETNAME\"\n\n    def connectionMade(self):\n        self.sendLine(b\"What's your name?\")\n\n    def connectionLost(self, reason):\n        if self.name in self.users:\n            del self.users[self.name]\n\n    def lineReceived(self, line):\n        if self.state == \"GETNAME\":\n            self.handle_GETNAME(line)\n        else:\n            self.handle_CHAT(line)\n\n    def handle_GETNAME(self, name):\n        if name in self.users:\n            self.sendLine(b\"Name taken, please choose another.\")\n            return\n        self.sendLine(f\"Welcome, {name.decode('utf-8')}!\".encode(\"utf-8\"))\n        self.name = name\n        self.users[name] = self\n        self.state = \"CHAT\"\n\n    def handle_CHAT(self, message):\n        message = f\"<{self.name.decode('utf-8')}> {message.decode('utf-8')}\".encode(\n            \"utf-8\"\n        )\n        for name, protocol in self.users.items():\n            if protocol != self:\n                protocol.sendLine(message)\n\n\nclass ChatFactory(Factory):\n    def __init__(self):\n        self.users = {}  # maps user names to Chat instances\n\n    def buildProtocol(self, addr):\n        return Chat(self.users)\n\n\nreactor.listenTCP(8123, ChatFactory())\nreactor.run()\n", "path": "docs/core/howto/listings/servers/chat.py"}], "after_files": [{"content": "from twisted.internet import reactor\nfrom twisted.internet.protocol import Factory\nfrom twisted.protocols.basic import LineReceiver\n\n\nclass Chat(LineReceiver):\n    def __init__(self, users):\n        self.users = users\n        self.name = None\n        self.state = \"GETNAME\"\n\n    def connectionMade(self):\n        self.sendLine(b\"What's your name?\")\n\n    def connectionLost(self, reason):\n        if self.name in self.users:\n            del self.users[self.name]\n\n    def lineReceived(self, line):\n        if self.state == \"GETNAME\":\n            self.handle_GETNAME(line)\n        else:\n            self.handle_CHAT(line)\n\n    def handle_GETNAME(self, name):\n        if name in self.users:\n            self.sendLine(b\"Name taken, please choose another.\")\n            return\n        self.sendLine(f\"Welcome, {name.decode('utf-8')}!\".encode(\"utf-8\"))\n        self.name = name\n        self.users[name] = self\n        self.state = \"CHAT\"\n\n    def handle_CHAT(self, message):\n        message = b\"<\" + self.name + b\"> \" + message\n        for name, protocol in self.users.items():\n            if protocol != self:\n                protocol.sendLine(message)\n\n\nclass ChatFactory(Factory):\n    def __init__(self):\n        self.users = {}  # maps user names to Chat instances\n\n    def buildProtocol(self, addr):\n        return Chat(self.users)\n\n\nreactor.listenTCP(8123, ChatFactory())\nreactor.run()\n", "path": "docs/core/howto/listings/servers/chat.py"}]}