We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove py2 leftovers
This is an issue to track all of the py2 stuff we can remove once a sufficient waiting period after 6.0 has passed.

- [x] Remove `zerorpc` (py2 only)
- [x] Remove `compat.py`
- [x] Run `pyupgrade`?

Ref #928 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `elasticapm/contrib/zerorpc/__init__.py`
Content:
```
1 #  BSD 3-Clause License
2 #
3 #  Copyright (c) 2012, the Sentry Team, see AUTHORS for more details
4 #  Copyright (c) 2019, Elasticsearch BV
5 #  All rights reserved.
6 #
7 #  Redistribution and use in source and binary forms, with or without
8 #  modification, are permitted provided that the following conditions are met:
9 #
10 #  * Redistributions of source code must retain the above copyright notice, this
11 #    list of conditions and the following disclaimer.
12 #
13 #  * Redistributions in binary form must reproduce the above copyright notice,
14 #    this list of conditions and the following disclaimer in the documentation
15 #    and/or other materials provided with the distribution.
16 #
17 #  * Neither the name of the copyright holder nor the names of its
18 #    contributors may be used to endorse or promote products derived from
19 #    this software without specific prior written permission.
20 #
21 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 #  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 #  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 #  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 #  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 #  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 #  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 
31 
32 import inspect
33 
34 from elasticapm.base import Client
35 
36 
37 class Middleware(object):
38     """ElasticAPM middleware for ZeroRPC.
39 
40     >>> elasticapm = Middleware(service_name='..', secret_token='...')
41     >>> zerorpc.Context.get_instance().register_middleware(elasticapm)
42 
43     Exceptions detected server-side in ZeroRPC will be submitted to the apm server (and
44     propagated to the client as well).
45     """
46 
47     def __init__(self, hide_zerorpc_frames=True, client=None, **kwargs):
48         """Create a middleware object that can be injected in a ZeroRPC server.
49 
50         - hide_zerorpc_frames: modify the exception stacktrace to remove the
51                                internal zerorpc frames (True by default to make
52                                the stacktrace as readable as possible);
53         - client: use an existing raven.Client object, otherwise one will be
54                   instantiated from the keyword arguments.
55 
56         """
57         self._elasticapm_client = client or Client(**kwargs)
58         self._hide_zerorpc_frames = hide_zerorpc_frames
59 
60     def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info):
61         """Called when an exception has been raised in the code run by ZeroRPC"""
62 
63         # Hide the zerorpc internal frames for readability, for a REQ/REP or
64         # REQ/STREAM server the frames to hide are:
65         # - core.ServerBase._async_task
66         # - core.Pattern*.process_call
67         # - core.DecoratorBase.__call__
68         #
69         # For a PUSH/PULL or PUB/SUB server the frame to hide is:
70         # - core.Puller._receiver
71         if self._hide_zerorpc_frames:
72             traceback = exc_info[2]
73             while traceback:
74                 zerorpc_frame = traceback.tb_frame
75                 zerorpc_frame.f_locals["__traceback_hide__"] = True
76                 frame_info = inspect.getframeinfo(zerorpc_frame)
77                 # Is there a better way than this (or looking up the filenames
78                 # or hardcoding the number of frames to skip) to know when we
79                 # are out of zerorpc?
80                 if frame_info.function == "__call__" or frame_info.function == "_receiver":
81                     break
82                 traceback = traceback.tb_next
83 
84         self._elasticapm_client.capture_exception(exc_info, extra=task_ctx, handled=False)
85
```
--- 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/elasticapm/contrib/zerorpc/__init__.py b/elasticapm/contrib/zerorpc/__init__.py
deleted file mode 100644
--- a/elasticapm/contrib/zerorpc/__init__.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#  BSD 3-Clause License
-#
-#  Copyright (c) 2012, the Sentry Team, see AUTHORS for more details
-#  Copyright (c) 2019, Elasticsearch BV
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions are met:
-#
-#  * Redistributions of source code must retain the above copyright notice, this
-#    list of conditions and the following disclaimer.
-#
-#  * Redistributions in binary form must reproduce the above copyright notice,
-#    this list of conditions and the following disclaimer in the documentation
-#    and/or other materials provided with the distribution.
-#
-#  * Neither the name of the copyright holder nor the names of its
-#    contributors may be used to endorse or promote products derived from
-#    this software without specific prior written permission.
-#
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
-
-import inspect
-
-from elasticapm.base import Client
-
-
-class Middleware(object):
-    """ElasticAPM middleware for ZeroRPC.
-
-    >>> elasticapm = Middleware(service_name='..', secret_token='...')
-    >>> zerorpc.Context.get_instance().register_middleware(elasticapm)
-
-    Exceptions detected server-side in ZeroRPC will be submitted to the apm server (and
-    propagated to the client as well).
-    """
-
-    def __init__(self, hide_zerorpc_frames=True, client=None, **kwargs):
-        """Create a middleware object that can be injected in a ZeroRPC server.
-
-        - hide_zerorpc_frames: modify the exception stacktrace to remove the
-                               internal zerorpc frames (True by default to make
-                               the stacktrace as readable as possible);
-        - client: use an existing raven.Client object, otherwise one will be
-                  instantiated from the keyword arguments.
-
-        """
-        self._elasticapm_client = client or Client(**kwargs)
-        self._hide_zerorpc_frames = hide_zerorpc_frames
-
-    def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info):
-        """Called when an exception has been raised in the code run by ZeroRPC"""
-
-        # Hide the zerorpc internal frames for readability, for a REQ/REP or
-        # REQ/STREAM server the frames to hide are:
-        # - core.ServerBase._async_task
-        # - core.Pattern*.process_call
-        # - core.DecoratorBase.__call__
-        #
-        # For a PUSH/PULL or PUB/SUB server the frame to hide is:
-        # - core.Puller._receiver
-        if self._hide_zerorpc_frames:
-            traceback = exc_info[2]
-            while traceback:
-                zerorpc_frame = traceback.tb_frame
-                zerorpc_frame.f_locals["__traceback_hide__"] = True
-                frame_info = inspect.getframeinfo(zerorpc_frame)
-                # Is there a better way than this (or looking up the filenames
-                # or hardcoding the number of frames to skip) to know when we
-                # are out of zerorpc?
-                if frame_info.function == "__call__" or frame_info.function == "_receiver":
-                    break
-                traceback = traceback.tb_next
-
-        self._elasticapm_client.capture_exception(exc_info, extra=task_ctx, handled=False)

{"golden_diff": "diff --git a/elasticapm/contrib/zerorpc/__init__.py b/elasticapm/contrib/zerorpc/__init__.py\ndeleted file mode 100644\n--- a/elasticapm/contrib/zerorpc/__init__.py\n+++ /dev/null\n@@ -1,84 +0,0 @@\n-#  BSD 3-Clause License\n-#\n-#  Copyright (c) 2012, the Sentry Team, see AUTHORS for more details\n-#  Copyright (c) 2019, Elasticsearch BV\n-#  All rights reserved.\n-#\n-#  Redistribution and use in source and binary forms, with or without\n-#  modification, are permitted provided that the following conditions are met:\n-#\n-#  * Redistributions of source code must retain the above copyright notice, this\n-#    list of conditions and the following disclaimer.\n-#\n-#  * Redistributions in binary form must reproduce the above copyright notice,\n-#    this list of conditions and the following disclaimer in the documentation\n-#    and/or other materials provided with the distribution.\n-#\n-#  * Neither the name of the copyright holder nor the names of its\n-#    contributors may be used to endorse or promote products derived from\n-#    this software without specific prior written permission.\n-#\n-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n-#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n-#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n-#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n-#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n-#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n-#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n-\n-\n-import inspect\n-\n-from elasticapm.base import Client\n-\n-\n-class Middleware(object):\n-    \"\"\"ElasticAPM middleware for ZeroRPC.\n-\n-    >>> elasticapm = Middleware(service_name='..', secret_token='...')\n-    >>> zerorpc.Context.get_instance().register_middleware(elasticapm)\n-\n-    Exceptions detected server-side in ZeroRPC will be submitted to the apm server (and\n-    propagated to the client as well).\n-    \"\"\"\n-\n-    def __init__(self, hide_zerorpc_frames=True, client=None, **kwargs):\n-        \"\"\"Create a middleware object that can be injected in a ZeroRPC server.\n-\n-        - hide_zerorpc_frames: modify the exception stacktrace to remove the\n-                               internal zerorpc frames (True by default to make\n-                               the stacktrace as readable as possible);\n-        - client: use an existing raven.Client object, otherwise one will be\n-                  instantiated from the keyword arguments.\n-\n-        \"\"\"\n-        self._elasticapm_client = client or Client(**kwargs)\n-        self._hide_zerorpc_frames = hide_zerorpc_frames\n-\n-    def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info):\n-        \"\"\"Called when an exception has been raised in the code run by ZeroRPC\"\"\"\n-\n-        # Hide the zerorpc internal frames for readability, for a REQ/REP or\n-        # REQ/STREAM server the frames to hide are:\n-        # - core.ServerBase._async_task\n-        # - core.Pattern*.process_call\n-        # - core.DecoratorBase.__call__\n-        #\n-        # For a PUSH/PULL or PUB/SUB server the frame to hide is:\n-        # - core.Puller._receiver\n-        if self._hide_zerorpc_frames:\n-            traceback = exc_info[2]\n-            while traceback:\n-                zerorpc_frame = traceback.tb_frame\n-                zerorpc_frame.f_locals[\"__traceback_hide__\"] = True\n-                frame_info = inspect.getframeinfo(zerorpc_frame)\n-                # Is there a better way than this (or looking up the filenames\n-                # or hardcoding the number of frames to skip) to know when we\n-                # are out of zerorpc?\n-                if frame_info.function == \"__call__\" or frame_info.function == \"_receiver\":\n-                    break\n-                traceback = traceback.tb_next\n-\n-        self._elasticapm_client.capture_exception(exc_info, extra=task_ctx, handled=False)\n", "issue": "Remove py2 leftovers\nThis is an issue to track all of the py2 stuff we can remove once a sufficient waiting period after 6.0 has passed.\r\n\r\n- [x] Remove `zerorpc` (py2 only)\r\n- [x] Remove `compat.py`\r\n- [x] Run `pyupgrade`?\r\n\r\nRef #928 \n", "before_files": [{"content": "#  BSD 3-Clause License\n#\n#  Copyright (c) 2012, the Sentry Team, see AUTHORS for more details\n#  Copyright (c) 2019, Elasticsearch BV\n#  All rights reserved.\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are met:\n#\n#  * Redistributions of source code must retain the above copyright notice, this\n#    list of conditions and the following disclaimer.\n#\n#  * Redistributions in binary form must reproduce the above copyright notice,\n#    this list of conditions and the following disclaimer in the documentation\n#    and/or other materials provided with the distribution.\n#\n#  * Neither the name of the copyright holder nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\n\nimport inspect\n\nfrom elasticapm.base import Client\n\n\nclass Middleware(object):\n    \"\"\"ElasticAPM middleware for ZeroRPC.\n\n    >>> elasticapm = Middleware(service_name='..', secret_token='...')\n    >>> zerorpc.Context.get_instance().register_middleware(elasticapm)\n\n    Exceptions detected server-side in ZeroRPC will be submitted to the apm server (and\n    propagated to the client as well).\n    \"\"\"\n\n    def __init__(self, hide_zerorpc_frames=True, client=None, **kwargs):\n        \"\"\"Create a middleware object that can be injected in a ZeroRPC server.\n\n        - hide_zerorpc_frames: modify the exception stacktrace to remove the\n                               internal zerorpc frames (True by default to make\n                               the stacktrace as readable as possible);\n        - client: use an existing raven.Client object, otherwise one will be\n                  instantiated from the keyword arguments.\n\n        \"\"\"\n        self._elasticapm_client = client or Client(**kwargs)\n        self._hide_zerorpc_frames = hide_zerorpc_frames\n\n    def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info):\n        \"\"\"Called when an exception has been raised in the code run by ZeroRPC\"\"\"\n\n        # Hide the zerorpc internal frames for readability, for a REQ/REP or\n        # REQ/STREAM server the frames to hide are:\n        # - core.ServerBase._async_task\n        # - core.Pattern*.process_call\n        # - core.DecoratorBase.__call__\n        #\n        # For a PUSH/PULL or PUB/SUB server the frame to hide is:\n        # - core.Puller._receiver\n        if self._hide_zerorpc_frames:\n            traceback = exc_info[2]\n            while traceback:\n                zerorpc_frame = traceback.tb_frame\n                zerorpc_frame.f_locals[\"__traceback_hide__\"] = True\n                frame_info = inspect.getframeinfo(zerorpc_frame)\n                # Is there a better way than this (or looking up the filenames\n                # or hardcoding the number of frames to skip) to know when we\n                # are out of zerorpc?\n                if frame_info.function == \"__call__\" or frame_info.function == \"_receiver\":\n                    break\n                traceback = traceback.tb_next\n\n        self._elasticapm_client.capture_exception(exc_info, extra=task_ctx, handled=False)\n", "path": "elasticapm/contrib/zerorpc/__init__.py"}], "after_files": [{"content": null, "path": "elasticapm/contrib/zerorpc/__init__.py"}]}