We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove unstable flags for MSC3283
#11933 added support for the stable flags in MSC3283, so we should remove the unstable ones in the next release

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `synapse/rest/client/capabilities.py`
Content:
```
1 # Copyright 2019 New Vector
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import logging
15 from http import HTTPStatus
16 from typing import TYPE_CHECKING, Tuple
17 
18 from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, MSC3244_CAPABILITIES
19 from synapse.http.server import HttpServer
20 from synapse.http.servlet import RestServlet
21 from synapse.http.site import SynapseRequest
22 from synapse.types import JsonDict
23 
24 from ._base import client_patterns
25 
26 if TYPE_CHECKING:
27     from synapse.server import HomeServer
28 
29 logger = logging.getLogger(__name__)
30 
31 
32 class CapabilitiesRestServlet(RestServlet):
33     """End point to expose the capabilities of the server."""
34 
35     PATTERNS = client_patterns("/capabilities$")
36 
37     def __init__(self, hs: "HomeServer"):
38         super().__init__()
39         self.hs = hs
40         self.config = hs.config
41         self.auth = hs.get_auth()
42         self.auth_handler = hs.get_auth_handler()
43 
44     async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
45         await self.auth.get_user_by_req(request, allow_guest=True)
46         change_password = self.auth_handler.can_change_password()
47 
48         response: JsonDict = {
49             "capabilities": {
50                 "m.room_versions": {
51                     "default": self.config.server.default_room_version.identifier,
52                     "available": {
53                         v.identifier: v.disposition
54                         for v in KNOWN_ROOM_VERSIONS.values()
55                     },
56                 },
57                 "m.change_password": {"enabled": change_password},
58                 "m.set_displayname": {
59                     "enabled": self.config.registration.enable_set_displayname
60                 },
61                 "m.set_avatar_url": {
62                     "enabled": self.config.registration.enable_set_avatar_url
63                 },
64                 "m.3pid_changes": {
65                     "enabled": self.config.registration.enable_3pid_changes
66                 },
67             }
68         }
69 
70         if self.config.experimental.msc3244_enabled:
71             response["capabilities"]["m.room_versions"][
72                 "org.matrix.msc3244.room_capabilities"
73             ] = MSC3244_CAPABILITIES
74 
75         # Must be removed in later versions.
76         # Is only included for migration.
77         # Also the parts in `synapse/config/experimental.py`.
78         if self.config.experimental.msc3283_enabled:
79             response["capabilities"]["org.matrix.msc3283.set_displayname"] = {
80                 "enabled": self.config.registration.enable_set_displayname
81             }
82             response["capabilities"]["org.matrix.msc3283.set_avatar_url"] = {
83                 "enabled": self.config.registration.enable_set_avatar_url
84             }
85             response["capabilities"]["org.matrix.msc3283.3pid_changes"] = {
86                 "enabled": self.config.registration.enable_3pid_changes
87             }
88 
89         if self.config.experimental.msc3440_enabled:
90             response["capabilities"]["io.element.thread"] = {"enabled": True}
91 
92         return HTTPStatus.OK, response
93 
94 
95 def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
96     CapabilitiesRestServlet(hs).register(http_server)
97
```

Path: `synapse/config/experimental.py`
Content:
```
1 # Copyright 2021 The Matrix.org Foundation C.I.C.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from synapse.config._base import Config
16 from synapse.types import JsonDict
17 
18 
19 class ExperimentalConfig(Config):
20     """Config section for enabling experimental features"""
21 
22     section = "experimental"
23 
24     def read_config(self, config: JsonDict, **kwargs):
25         experimental = config.get("experimental_features") or {}
26 
27         # MSC3440 (thread relation)
28         self.msc3440_enabled: bool = experimental.get("msc3440_enabled", False)
29         # MSC3666: including bundled relations in /search.
30         self.msc3666_enabled: bool = experimental.get("msc3666_enabled", False)
31 
32         # MSC3026 (busy presence state)
33         self.msc3026_enabled: bool = experimental.get("msc3026_enabled", False)
34 
35         # MSC2716 (importing historical messages)
36         self.msc2716_enabled: bool = experimental.get("msc2716_enabled", False)
37 
38         # MSC2285 (hidden read receipts)
39         self.msc2285_enabled: bool = experimental.get("msc2285_enabled", False)
40 
41         # MSC3244 (room version capabilities)
42         self.msc3244_enabled: bool = experimental.get("msc3244_enabled", True)
43 
44         # MSC3283 (set displayname, avatar_url and change 3pid capabilities)
45         self.msc3283_enabled: bool = experimental.get("msc3283_enabled", False)
46 
47         # MSC3266 (room summary api)
48         self.msc3266_enabled: bool = experimental.get("msc3266_enabled", False)
49 
50         # MSC3030 (Jump to date API endpoint)
51         self.msc3030_enabled: bool = experimental.get("msc3030_enabled", False)
52 
53         # The portion of MSC3202 which is related to device masquerading.
54         self.msc3202_device_masquerading_enabled: bool = experimental.get(
55             "msc3202_device_masquerading", False
56         )
57 
58         # MSC2409 (this setting only relates to optionally sending to-device messages).
59         # Presence, typing and read receipt EDUs are already sent to application services that
60         # have opted in to receive them. If enabled, this adds to-device messages to that list.
61         self.msc2409_to_device_messages_enabled: bool = experimental.get(
62             "msc2409_to_device_messages_enabled", False
63         )
64 
65         # MSC3706 (server-side support for partial state in /send_join responses)
66         self.msc3706_enabled: bool = experimental.get("msc3706_enabled", False)
67 
68         # experimental support for faster joins over federation (msc2775, msc3706)
69         # requires a target server with msc3706_enabled enabled.
70         self.faster_joins_enabled: bool = experimental.get("faster_joins", False)
71
```
--- 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()

```

diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py
--- a/synapse/config/experimental.py
+++ b/synapse/config/experimental.py
@@ -41,9 +41,6 @@
         # MSC3244 (room version capabilities)
         self.msc3244_enabled: bool = experimental.get("msc3244_enabled", True)
 
-        # MSC3283 (set displayname, avatar_url and change 3pid capabilities)
-        self.msc3283_enabled: bool = experimental.get("msc3283_enabled", False)
-
         # MSC3266 (room summary api)
         self.msc3266_enabled: bool = experimental.get("msc3266_enabled", False)
 
diff --git a/synapse/rest/client/capabilities.py b/synapse/rest/client/capabilities.py
--- a/synapse/rest/client/capabilities.py
+++ b/synapse/rest/client/capabilities.py
@@ -72,20 +72,6 @@
                 "org.matrix.msc3244.room_capabilities"
             ] = MSC3244_CAPABILITIES
 
-        # Must be removed in later versions.
-        # Is only included for migration.
-        # Also the parts in `synapse/config/experimental.py`.
-        if self.config.experimental.msc3283_enabled:
-            response["capabilities"]["org.matrix.msc3283.set_displayname"] = {
-                "enabled": self.config.registration.enable_set_displayname
-            }
-            response["capabilities"]["org.matrix.msc3283.set_avatar_url"] = {
-                "enabled": self.config.registration.enable_set_avatar_url
-            }
-            response["capabilities"]["org.matrix.msc3283.3pid_changes"] = {
-                "enabled": self.config.registration.enable_3pid_changes
-            }
-
         if self.config.experimental.msc3440_enabled:
             response["capabilities"]["io.element.thread"] = {"enabled": True}

{"golden_diff": "diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py\n--- a/synapse/config/experimental.py\n+++ b/synapse/config/experimental.py\n@@ -41,9 +41,6 @@\n         # MSC3244 (room version capabilities)\n         self.msc3244_enabled: bool = experimental.get(\"msc3244_enabled\", True)\n \n-        # MSC3283 (set displayname, avatar_url and change 3pid capabilities)\n-        self.msc3283_enabled: bool = experimental.get(\"msc3283_enabled\", False)\n-\n         # MSC3266 (room summary api)\n         self.msc3266_enabled: bool = experimental.get(\"msc3266_enabled\", False)\n \ndiff --git a/synapse/rest/client/capabilities.py b/synapse/rest/client/capabilities.py\n--- a/synapse/rest/client/capabilities.py\n+++ b/synapse/rest/client/capabilities.py\n@@ -72,20 +72,6 @@\n                 \"org.matrix.msc3244.room_capabilities\"\n             ] = MSC3244_CAPABILITIES\n \n-        # Must be removed in later versions.\n-        # Is only included for migration.\n-        # Also the parts in `synapse/config/experimental.py`.\n-        if self.config.experimental.msc3283_enabled:\n-            response[\"capabilities\"][\"org.matrix.msc3283.set_displayname\"] = {\n-                \"enabled\": self.config.registration.enable_set_displayname\n-            }\n-            response[\"capabilities\"][\"org.matrix.msc3283.set_avatar_url\"] = {\n-                \"enabled\": self.config.registration.enable_set_avatar_url\n-            }\n-            response[\"capabilities\"][\"org.matrix.msc3283.3pid_changes\"] = {\n-                \"enabled\": self.config.registration.enable_3pid_changes\n-            }\n-\n         if self.config.experimental.msc3440_enabled:\n             response[\"capabilities\"][\"io.element.thread\"] = {\"enabled\": True}\n", "issue": "Remove unstable flags for MSC3283\n#11933 added support for the stable flags in MSC3283, so we should remove the unstable ones in the next release\n", "before_files": [{"content": "# Copyright 2019 New Vector\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport logging\nfrom http import HTTPStatus\nfrom typing import TYPE_CHECKING, Tuple\n\nfrom synapse.api.room_versions import KNOWN_ROOM_VERSIONS, MSC3244_CAPABILITIES\nfrom synapse.http.server import HttpServer\nfrom synapse.http.servlet import RestServlet\nfrom synapse.http.site import SynapseRequest\nfrom synapse.types import JsonDict\n\nfrom ._base import client_patterns\n\nif TYPE_CHECKING:\n    from synapse.server import HomeServer\n\nlogger = logging.getLogger(__name__)\n\n\nclass CapabilitiesRestServlet(RestServlet):\n    \"\"\"End point to expose the capabilities of the server.\"\"\"\n\n    PATTERNS = client_patterns(\"/capabilities$\")\n\n    def __init__(self, hs: \"HomeServer\"):\n        super().__init__()\n        self.hs = hs\n        self.config = hs.config\n        self.auth = hs.get_auth()\n        self.auth_handler = hs.get_auth_handler()\n\n    async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:\n        await self.auth.get_user_by_req(request, allow_guest=True)\n        change_password = self.auth_handler.can_change_password()\n\n        response: JsonDict = {\n            \"capabilities\": {\n                \"m.room_versions\": {\n                    \"default\": self.config.server.default_room_version.identifier,\n                    \"available\": {\n                        v.identifier: v.disposition\n                        for v in KNOWN_ROOM_VERSIONS.values()\n                    },\n                },\n                \"m.change_password\": {\"enabled\": change_password},\n                \"m.set_displayname\": {\n                    \"enabled\": self.config.registration.enable_set_displayname\n                },\n                \"m.set_avatar_url\": {\n                    \"enabled\": self.config.registration.enable_set_avatar_url\n                },\n                \"m.3pid_changes\": {\n                    \"enabled\": self.config.registration.enable_3pid_changes\n                },\n            }\n        }\n\n        if self.config.experimental.msc3244_enabled:\n            response[\"capabilities\"][\"m.room_versions\"][\n                \"org.matrix.msc3244.room_capabilities\"\n            ] = MSC3244_CAPABILITIES\n\n        # Must be removed in later versions.\n        # Is only included for migration.\n        # Also the parts in `synapse/config/experimental.py`.\n        if self.config.experimental.msc3283_enabled:\n            response[\"capabilities\"][\"org.matrix.msc3283.set_displayname\"] = {\n                \"enabled\": self.config.registration.enable_set_displayname\n            }\n            response[\"capabilities\"][\"org.matrix.msc3283.set_avatar_url\"] = {\n                \"enabled\": self.config.registration.enable_set_avatar_url\n            }\n            response[\"capabilities\"][\"org.matrix.msc3283.3pid_changes\"] = {\n                \"enabled\": self.config.registration.enable_3pid_changes\n            }\n\n        if self.config.experimental.msc3440_enabled:\n            response[\"capabilities\"][\"io.element.thread\"] = {\"enabled\": True}\n\n        return HTTPStatus.OK, response\n\n\ndef register_servlets(hs: \"HomeServer\", http_server: HttpServer) -> None:\n    CapabilitiesRestServlet(hs).register(http_server)\n", "path": "synapse/rest/client/capabilities.py"}, {"content": "# Copyright 2021 The Matrix.org Foundation C.I.C.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom synapse.config._base import Config\nfrom synapse.types import JsonDict\n\n\nclass ExperimentalConfig(Config):\n    \"\"\"Config section for enabling experimental features\"\"\"\n\n    section = \"experimental\"\n\n    def read_config(self, config: JsonDict, **kwargs):\n        experimental = config.get(\"experimental_features\") or {}\n\n        # MSC3440 (thread relation)\n        self.msc3440_enabled: bool = experimental.get(\"msc3440_enabled\", False)\n        # MSC3666: including bundled relations in /search.\n        self.msc3666_enabled: bool = experimental.get(\"msc3666_enabled\", False)\n\n        # MSC3026 (busy presence state)\n        self.msc3026_enabled: bool = experimental.get(\"msc3026_enabled\", False)\n\n        # MSC2716 (importing historical messages)\n        self.msc2716_enabled: bool = experimental.get(\"msc2716_enabled\", False)\n\n        # MSC2285 (hidden read receipts)\n        self.msc2285_enabled: bool = experimental.get(\"msc2285_enabled\", False)\n\n        # MSC3244 (room version capabilities)\n        self.msc3244_enabled: bool = experimental.get(\"msc3244_enabled\", True)\n\n        # MSC3283 (set displayname, avatar_url and change 3pid capabilities)\n        self.msc3283_enabled: bool = experimental.get(\"msc3283_enabled\", False)\n\n        # MSC3266 (room summary api)\n        self.msc3266_enabled: bool = experimental.get(\"msc3266_enabled\", False)\n\n        # MSC3030 (Jump to date API endpoint)\n        self.msc3030_enabled: bool = experimental.get(\"msc3030_enabled\", False)\n\n        # The portion of MSC3202 which is related to device masquerading.\n        self.msc3202_device_masquerading_enabled: bool = experimental.get(\n            \"msc3202_device_masquerading\", False\n        )\n\n        # MSC2409 (this setting only relates to optionally sending to-device messages).\n        # Presence, typing and read receipt EDUs are already sent to application services that\n        # have opted in to receive them. If enabled, this adds to-device messages to that list.\n        self.msc2409_to_device_messages_enabled: bool = experimental.get(\n            \"msc2409_to_device_messages_enabled\", False\n        )\n\n        # MSC3706 (server-side support for partial state in /send_join responses)\n        self.msc3706_enabled: bool = experimental.get(\"msc3706_enabled\", False)\n\n        # experimental support for faster joins over federation (msc2775, msc3706)\n        # requires a target server with msc3706_enabled enabled.\n        self.faster_joins_enabled: bool = experimental.get(\"faster_joins\", False)\n", "path": "synapse/config/experimental.py"}], "after_files": [{"content": "# Copyright 2019 New Vector\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport logging\nfrom http import HTTPStatus\nfrom typing import TYPE_CHECKING, Tuple\n\nfrom synapse.api.room_versions import KNOWN_ROOM_VERSIONS, MSC3244_CAPABILITIES\nfrom synapse.http.server import HttpServer\nfrom synapse.http.servlet import RestServlet\nfrom synapse.http.site import SynapseRequest\nfrom synapse.types import JsonDict\n\nfrom ._base import client_patterns\n\nif TYPE_CHECKING:\n    from synapse.server import HomeServer\n\nlogger = logging.getLogger(__name__)\n\n\nclass CapabilitiesRestServlet(RestServlet):\n    \"\"\"End point to expose the capabilities of the server.\"\"\"\n\n    PATTERNS = client_patterns(\"/capabilities$\")\n\n    def __init__(self, hs: \"HomeServer\"):\n        super().__init__()\n        self.hs = hs\n        self.config = hs.config\n        self.auth = hs.get_auth()\n        self.auth_handler = hs.get_auth_handler()\n\n    async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:\n        await self.auth.get_user_by_req(request, allow_guest=True)\n        change_password = self.auth_handler.can_change_password()\n\n        response: JsonDict = {\n            \"capabilities\": {\n                \"m.room_versions\": {\n                    \"default\": self.config.server.default_room_version.identifier,\n                    \"available\": {\n                        v.identifier: v.disposition\n                        for v in KNOWN_ROOM_VERSIONS.values()\n                    },\n                },\n                \"m.change_password\": {\"enabled\": change_password},\n                \"m.set_displayname\": {\n                    \"enabled\": self.config.registration.enable_set_displayname\n                },\n                \"m.set_avatar_url\": {\n                    \"enabled\": self.config.registration.enable_set_avatar_url\n                },\n                \"m.3pid_changes\": {\n                    \"enabled\": self.config.registration.enable_3pid_changes\n                },\n            }\n        }\n\n        if self.config.experimental.msc3244_enabled:\n            response[\"capabilities\"][\"m.room_versions\"][\n                \"org.matrix.msc3244.room_capabilities\"\n            ] = MSC3244_CAPABILITIES\n\n        if self.config.experimental.msc3440_enabled:\n            response[\"capabilities\"][\"io.element.thread\"] = {\"enabled\": True}\n\n        return HTTPStatus.OK, response\n\n\ndef register_servlets(hs: \"HomeServer\", http_server: HttpServer) -> None:\n    CapabilitiesRestServlet(hs).register(http_server)\n", "path": "synapse/rest/client/capabilities.py"}, {"content": "# Copyright 2021 The Matrix.org Foundation C.I.C.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom synapse.config._base import Config\nfrom synapse.types import JsonDict\n\n\nclass ExperimentalConfig(Config):\n    \"\"\"Config section for enabling experimental features\"\"\"\n\n    section = \"experimental\"\n\n    def read_config(self, config: JsonDict, **kwargs):\n        experimental = config.get(\"experimental_features\") or {}\n\n        # MSC3440 (thread relation)\n        self.msc3440_enabled: bool = experimental.get(\"msc3440_enabled\", False)\n        # MSC3666: including bundled relations in /search.\n        self.msc3666_enabled: bool = experimental.get(\"msc3666_enabled\", False)\n\n        # MSC3026 (busy presence state)\n        self.msc3026_enabled: bool = experimental.get(\"msc3026_enabled\", False)\n\n        # MSC2716 (importing historical messages)\n        self.msc2716_enabled: bool = experimental.get(\"msc2716_enabled\", False)\n\n        # MSC2285 (hidden read receipts)\n        self.msc2285_enabled: bool = experimental.get(\"msc2285_enabled\", False)\n\n        # MSC3244 (room version capabilities)\n        self.msc3244_enabled: bool = experimental.get(\"msc3244_enabled\", True)\n\n        # MSC3266 (room summary api)\n        self.msc3266_enabled: bool = experimental.get(\"msc3266_enabled\", False)\n\n        # MSC3030 (Jump to date API endpoint)\n        self.msc3030_enabled: bool = experimental.get(\"msc3030_enabled\", False)\n\n        # The portion of MSC3202 which is related to device masquerading.\n        self.msc3202_device_masquerading_enabled: bool = experimental.get(\n            \"msc3202_device_masquerading\", False\n        )\n\n        # MSC2409 (this setting only relates to optionally sending to-device messages).\n        # Presence, typing and read receipt EDUs are already sent to application services that\n        # have opted in to receive them. If enabled, this adds to-device messages to that list.\n        self.msc2409_to_device_messages_enabled: bool = experimental.get(\n            \"msc2409_to_device_messages_enabled\", False\n        )\n\n        # MSC3706 (server-side support for partial state in /send_join responses)\n        self.msc3706_enabled: bool = experimental.get(\"msc3706_enabled\", False)\n\n        # experimental support for faster joins over federation (msc2775, msc3706)\n        # requires a target server with msc3706_enabled enabled.\n        self.faster_joins_enabled: bool = experimental.get(\"faster_joins\", False)\n", "path": "synapse/config/experimental.py"}]}