We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add PyInstaller indicator to `mitmproxy --version`
We currently cannot distinguish if users use our precompiled binaries or if they installed mitmproxy using pip/brew/$packagemanager. It would be very useful to output if we are running the precompiled PyInstaller binary. 

https://pythonhosted.org/PyInstaller/runtime-information.html

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mitmproxy/utils/debug.py`
Content:
```
1 import gc
2 import os
3 import sys
4 import threading
5 import signal
6 import platform
7 import traceback
8 import subprocess
9 
10 from mitmproxy import version
11 from mitmproxy import utils
12 
13 from OpenSSL import SSL
14 
15 
16 def dump_system_info():
17     git_describe = 'release version'
18     with utils.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))):
19         try:
20             c = ['git', 'describe', '--tags', '--long']
21             git_describe = subprocess.check_output(c, stderr=subprocess.STDOUT)
22             last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2)
23 
24             if last_tag.startswith('v'):
25                 # remove the 'v' prefix
26                 last_tag = last_tag[1:]
27             if commit.startswith('g'):
28                 # remove the 'g' prefix added by recent git versions
29                 commit = commit[1:]
30 
31             # build the same version specifier as used for snapshots by rtool
32             git_describe = "{version}dev{tag:04}-0x{commit}".format(
33                 version=last_tag,
34                 tag=int(tag_dist),
35                 commit=commit,
36             )
37         except:
38             pass
39 
40     data = [
41         "Mitmproxy version: {} ({})".format(version.VERSION, git_describe),
42         "Python version: {}".format(platform.python_version()),
43         "Platform: {}".format(platform.platform()),
44         "SSL version: {}".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),
45     ]
46     d = platform.linux_distribution()
47     t = "Linux distro: %s %s %s" % d
48     if d[0]:  # pragma: no cover
49         data.append(t)
50 
51     d = platform.mac_ver()
52     t = "Mac version: %s %s %s" % d
53     if d[0]:  # pragma: no cover
54         data.append(t)
55 
56     d = platform.win32_ver()
57     t = "Windows version: %s %s %s %s" % d
58     if d[0]:  # pragma: no cover
59         data.append(t)
60 
61     return "\n".join(data)
62 
63 
64 def dump_info(signal=None, frame=None, file=sys.stdout, testing=False):  # pragma: no cover
65     print("****************************************************", file=file)
66     print("Summary", file=file)
67     print("=======", file=file)
68 
69     try:
70         import psutil
71     except:
72         print("(psutil not installed, skipping some debug info)", file=file)
73     else:
74         p = psutil.Process()
75         print("num threads: ", p.num_threads(), file=file)
76         if hasattr(p, "num_fds"):
77             print("num fds: ", p.num_fds(), file=file)
78         print("memory: ", p.memory_info(), file=file)
79 
80         print(file=file)
81         print("Files", file=file)
82         print("=====", file=file)
83         for i in p.open_files():
84             print(i, file=file)
85 
86         print(file=file)
87         print("Connections", file=file)
88         print("===========", file=file)
89         for i in p.connections():
90             print(i, file=file)
91 
92     print(file=file)
93     print("Threads", file=file)
94     print("=======", file=file)
95     bthreads = []
96     for i in threading.enumerate():
97         if hasattr(i, "_threadinfo"):
98             bthreads.append(i)
99         else:
100             print(i.name, file=file)
101     bthreads.sort(key=lambda x: x._thread_started)
102     for i in bthreads:
103         print(i._threadinfo(), file=file)
104 
105     print(file=file)
106     print("Memory", file=file)
107     print("=======", file=file)
108     gc.collect()
109     d = {}
110     for i in gc.get_objects():
111         t = str(type(i))
112         if "mitmproxy" in t:
113             d[t] = d.setdefault(t, 0) + 1
114     itms = list(d.items())
115     itms.sort(key=lambda x: x[1])
116     for i in itms[-20:]:
117         print(i[1], i[0], file=file)
118     print("****************************************************", file=file)
119 
120     if not testing:
121         sys.exit(1)
122 
123 
124 def dump_stacks(signal=None, frame=None, file=sys.stdout, testing=False):
125     id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
126     code = []
127     for threadId, stack in sys._current_frames().items():
128         code.append(
129             "\n# Thread: %s(%d)" % (
130                 id2name.get(threadId, ""), threadId
131             )
132         )
133         for filename, lineno, name, line in traceback.extract_stack(stack):
134             code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
135             if line:
136                 code.append("  %s" % (line.strip()))
137     print("\n".join(code), file=file)
138     if not testing:  # pragma: no cover
139         sys.exit(1)
140 
141 
142 def register_info_dumpers():
143     if os.name != "nt":  # pragma: windows no cover
144         signal.signal(signal.SIGUSR1, dump_info)
145         signal.signal(signal.SIGUSR2, dump_stacks)
146
```
--- 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/mitmproxy/utils/debug.py b/mitmproxy/utils/debug.py
--- a/mitmproxy/utils/debug.py
+++ b/mitmproxy/utils/debug.py
@@ -37,8 +37,12 @@
         except:
             pass
 
+    bin_indicator = ""  # PyInstaller builds indicator, if using precompiled binary
+    if getattr(sys, 'frozen', False):
+        bin_indicator = "Precompiled Binary"
+
     data = [
-        "Mitmproxy version: {} ({})".format(version.VERSION, git_describe),
+        "Mitmproxy version: {} ({}) {}".format(version.VERSION, git_describe, bin_indicator),
         "Python version: {}".format(platform.python_version()),
         "Platform: {}".format(platform.platform()),
         "SSL version: {}".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),

{"golden_diff": "diff --git a/mitmproxy/utils/debug.py b/mitmproxy/utils/debug.py\n--- a/mitmproxy/utils/debug.py\n+++ b/mitmproxy/utils/debug.py\n@@ -37,8 +37,12 @@\n         except:\n             pass\n \n+    bin_indicator = \"\"  # PyInstaller builds indicator, if using precompiled binary\n+    if getattr(sys, 'frozen', False):\n+        bin_indicator = \"Precompiled Binary\"\n+\n     data = [\n-        \"Mitmproxy version: {} ({})\".format(version.VERSION, git_describe),\n+        \"Mitmproxy version: {} ({}) {}\".format(version.VERSION, git_describe, bin_indicator),\n         \"Python version: {}\".format(platform.python_version()),\n         \"Platform: {}\".format(platform.platform()),\n         \"SSL version: {}\".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),\n", "issue": "Add PyInstaller indicator to `mitmproxy --version`\nWe currently cannot distinguish if users use our precompiled binaries or if they installed mitmproxy using pip/brew/$packagemanager. It would be very useful to output if we are running the precompiled PyInstaller binary. \r\n\r\nhttps://pythonhosted.org/PyInstaller/runtime-information.html\n", "before_files": [{"content": "import gc\nimport os\nimport sys\nimport threading\nimport signal\nimport platform\nimport traceback\nimport subprocess\n\nfrom mitmproxy import version\nfrom mitmproxy import utils\n\nfrom OpenSSL import SSL\n\n\ndef dump_system_info():\n    git_describe = 'release version'\n    with utils.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), \"..\"))):\n        try:\n            c = ['git', 'describe', '--tags', '--long']\n            git_describe = subprocess.check_output(c, stderr=subprocess.STDOUT)\n            last_tag, tag_dist, commit = git_describe.decode().strip().rsplit(\"-\", 2)\n\n            if last_tag.startswith('v'):\n                # remove the 'v' prefix\n                last_tag = last_tag[1:]\n            if commit.startswith('g'):\n                # remove the 'g' prefix added by recent git versions\n                commit = commit[1:]\n\n            # build the same version specifier as used for snapshots by rtool\n            git_describe = \"{version}dev{tag:04}-0x{commit}\".format(\n                version=last_tag,\n                tag=int(tag_dist),\n                commit=commit,\n            )\n        except:\n            pass\n\n    data = [\n        \"Mitmproxy version: {} ({})\".format(version.VERSION, git_describe),\n        \"Python version: {}\".format(platform.python_version()),\n        \"Platform: {}\".format(platform.platform()),\n        \"SSL version: {}\".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),\n    ]\n    d = platform.linux_distribution()\n    t = \"Linux distro: %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    d = platform.mac_ver()\n    t = \"Mac version: %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    d = platform.win32_ver()\n    t = \"Windows version: %s %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    return \"\\n\".join(data)\n\n\ndef dump_info(signal=None, frame=None, file=sys.stdout, testing=False):  # pragma: no cover\n    print(\"****************************************************\", file=file)\n    print(\"Summary\", file=file)\n    print(\"=======\", file=file)\n\n    try:\n        import psutil\n    except:\n        print(\"(psutil not installed, skipping some debug info)\", file=file)\n    else:\n        p = psutil.Process()\n        print(\"num threads: \", p.num_threads(), file=file)\n        if hasattr(p, \"num_fds\"):\n            print(\"num fds: \", p.num_fds(), file=file)\n        print(\"memory: \", p.memory_info(), file=file)\n\n        print(file=file)\n        print(\"Files\", file=file)\n        print(\"=====\", file=file)\n        for i in p.open_files():\n            print(i, file=file)\n\n        print(file=file)\n        print(\"Connections\", file=file)\n        print(\"===========\", file=file)\n        for i in p.connections():\n            print(i, file=file)\n\n    print(file=file)\n    print(\"Threads\", file=file)\n    print(\"=======\", file=file)\n    bthreads = []\n    for i in threading.enumerate():\n        if hasattr(i, \"_threadinfo\"):\n            bthreads.append(i)\n        else:\n            print(i.name, file=file)\n    bthreads.sort(key=lambda x: x._thread_started)\n    for i in bthreads:\n        print(i._threadinfo(), file=file)\n\n    print(file=file)\n    print(\"Memory\", file=file)\n    print(\"=======\", file=file)\n    gc.collect()\n    d = {}\n    for i in gc.get_objects():\n        t = str(type(i))\n        if \"mitmproxy\" in t:\n            d[t] = d.setdefault(t, 0) + 1\n    itms = list(d.items())\n    itms.sort(key=lambda x: x[1])\n    for i in itms[-20:]:\n        print(i[1], i[0], file=file)\n    print(\"****************************************************\", file=file)\n\n    if not testing:\n        sys.exit(1)\n\n\ndef dump_stacks(signal=None, frame=None, file=sys.stdout, testing=False):\n    id2name = dict([(th.ident, th.name) for th in threading.enumerate()])\n    code = []\n    for threadId, stack in sys._current_frames().items():\n        code.append(\n            \"\\n# Thread: %s(%d)\" % (\n                id2name.get(threadId, \"\"), threadId\n            )\n        )\n        for filename, lineno, name, line in traceback.extract_stack(stack):\n            code.append('File: \"%s\", line %d, in %s' % (filename, lineno, name))\n            if line:\n                code.append(\"  %s\" % (line.strip()))\n    print(\"\\n\".join(code), file=file)\n    if not testing:  # pragma: no cover\n        sys.exit(1)\n\n\ndef register_info_dumpers():\n    if os.name != \"nt\":  # pragma: windows no cover\n        signal.signal(signal.SIGUSR1, dump_info)\n        signal.signal(signal.SIGUSR2, dump_stacks)\n", "path": "mitmproxy/utils/debug.py"}], "after_files": [{"content": "import gc\nimport os\nimport sys\nimport threading\nimport signal\nimport platform\nimport traceback\nimport subprocess\n\nfrom mitmproxy import version\nfrom mitmproxy import utils\n\nfrom OpenSSL import SSL\n\n\ndef dump_system_info():\n    git_describe = 'release version'\n    with utils.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), \"..\"))):\n        try:\n            c = ['git', 'describe', '--tags', '--long']\n            git_describe = subprocess.check_output(c, stderr=subprocess.STDOUT)\n            last_tag, tag_dist, commit = git_describe.decode().strip().rsplit(\"-\", 2)\n\n            if last_tag.startswith('v'):\n                # remove the 'v' prefix\n                last_tag = last_tag[1:]\n            if commit.startswith('g'):\n                # remove the 'g' prefix added by recent git versions\n                commit = commit[1:]\n\n            # build the same version specifier as used for snapshots by rtool\n            git_describe = \"{version}dev{tag:04}-0x{commit}\".format(\n                version=last_tag,\n                tag=int(tag_dist),\n                commit=commit,\n            )\n        except:\n            pass\n\n    bin_indicator = \"\"  # PyInstaller builds indicator, if using precompiled binary\n    if getattr(sys, 'frozen', False):\n        bin_indicator = \"Precompiled Binary\"\n\n    data = [\n        \"Mitmproxy version: {} ({}) {}\".format(version.VERSION, git_describe, bin_indicator),\n        \"Python version: {}\".format(platform.python_version()),\n        \"Platform: {}\".format(platform.platform()),\n        \"SSL version: {}\".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),\n    ]\n    d = platform.linux_distribution()\n    t = \"Linux distro: %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    d = platform.mac_ver()\n    t = \"Mac version: %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    d = platform.win32_ver()\n    t = \"Windows version: %s %s %s %s\" % d\n    if d[0]:  # pragma: no cover\n        data.append(t)\n\n    return \"\\n\".join(data)\n\n\ndef dump_info(signal=None, frame=None, file=sys.stdout, testing=False):  # pragma: no cover\n    print(\"****************************************************\", file=file)\n    print(\"Summary\", file=file)\n    print(\"=======\", file=file)\n\n    try:\n        import psutil\n    except:\n        print(\"(psutil not installed, skipping some debug info)\", file=file)\n    else:\n        p = psutil.Process()\n        print(\"num threads: \", p.num_threads(), file=file)\n        if hasattr(p, \"num_fds\"):\n            print(\"num fds: \", p.num_fds(), file=file)\n        print(\"memory: \", p.memory_info(), file=file)\n\n        print(file=file)\n        print(\"Files\", file=file)\n        print(\"=====\", file=file)\n        for i in p.open_files():\n            print(i, file=file)\n\n        print(file=file)\n        print(\"Connections\", file=file)\n        print(\"===========\", file=file)\n        for i in p.connections():\n            print(i, file=file)\n\n    print(file=file)\n    print(\"Threads\", file=file)\n    print(\"=======\", file=file)\n    bthreads = []\n    for i in threading.enumerate():\n        if hasattr(i, \"_threadinfo\"):\n            bthreads.append(i)\n        else:\n            print(i.name, file=file)\n    bthreads.sort(key=lambda x: x._thread_started)\n    for i in bthreads:\n        print(i._threadinfo(), file=file)\n\n    print(file=file)\n    print(\"Memory\", file=file)\n    print(\"=======\", file=file)\n    gc.collect()\n    d = {}\n    for i in gc.get_objects():\n        t = str(type(i))\n        if \"mitmproxy\" in t:\n            d[t] = d.setdefault(t, 0) + 1\n    itms = list(d.items())\n    itms.sort(key=lambda x: x[1])\n    for i in itms[-20:]:\n        print(i[1], i[0], file=file)\n    print(\"****************************************************\", file=file)\n\n    if not testing:\n        sys.exit(1)\n\n\ndef dump_stacks(signal=None, frame=None, file=sys.stdout, testing=False):\n    id2name = dict([(th.ident, th.name) for th in threading.enumerate()])\n    code = []\n    for threadId, stack in sys._current_frames().items():\n        code.append(\n            \"\\n# Thread: %s(%d)\" % (\n                id2name.get(threadId, \"\"), threadId\n            )\n        )\n        for filename, lineno, name, line in traceback.extract_stack(stack):\n            code.append('File: \"%s\", line %d, in %s' % (filename, lineno, name))\n            if line:\n                code.append(\"  %s\" % (line.strip()))\n    print(\"\\n\".join(code), file=file)\n    if not testing:  # pragma: no cover\n        sys.exit(1)\n\n\ndef register_info_dumpers():\n    if os.name != \"nt\":  # pragma: windows no cover\n        signal.signal(signal.SIGUSR1, dump_info)\n        signal.signal(signal.SIGUSR2, dump_stacks)\n", "path": "mitmproxy/utils/debug.py"}]}