We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ptvsd broken on Python 2 if python-future is installed
Issue Type: <b>Bug</b>

After I installed an interpreter of Python 2.7.16 32bit, an exception is thrown with error message below when I want to switch to the old Python 2.7.16 64bit:
```
E+00000.045: /handling microsoft/vscode-python#1 request "launch" from Adapter-1/
             Handler 'launch_request' (file u'c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\launcher\\adapter.py', line 35)
             couldn't handle microsoft/vscode-python#1 request "launch" from Adapter-1:

             Traceback (most recent call last):
               File "c:\Users\linshimeng01\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\launcher/../../ptvsd\common\messaging.py", line 763, in _handle
                 result = handler(self)
               File "c:\Users\linshimeng01\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\launcher/../../ptvsd\launcher\adapter.py", line 147, in launch_request
                 debuggee.spawn(process_name, cmdline, cwd, env, redirect_output)
               File "c:\Users\linshimeng01\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\launcher/../../ptvsd\launcher\debuggee.py", line 64, in spawn
                 "Couldn't spawn debuggee: {0}\n\nCommand line:{1!r}", exc, cmdline
             TypeError: unbound method cant_handle() must be called with Message instance as first argument (got unicode instance instead)

             Stack where logged:
               File "C:\Python27-32\lib\threading.py", line 774, in __bootstrap
                 self.__bootstrap_inner()
               File "C:\Python27-32\lib\threading.py", line 801, in __bootstrap_inner
                 self.run()
               File "C:\Python27-32\lib\threading.py", line 754, in run
                 self.__target(*self.__args, **self.__kwargs)
               File "c:\Users\linshimeng01\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\launcher/../../ptvsd\common\messaging.py", line 1520, in _run_handlers
                 handler()
               File "c:\Users\linshimeng01\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\launcher/../../ptvsd\common\messaging.py", line 809, in _handle
                 self.describe(),
```
Now I installed an Python 3 interpreter, and I found the two Python 2 interpreter are all unavailable and throw the same error message above as well when I attempt to run a python file. How can I fix it?

Extension version: 2019.11.50794
VS Code version: Code 1.40.1 (8795a9889db74563ddd43eb0a897a2384129a619, 2019-11-13T16:49:35.976Z)
OS version: Windows_NT x64 10.0.17763

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz (6 x 2904)|
|GPU Status|2d_canvas: enabled<br>flash_3d: enabled<br>flash_stage3d: enabled<br>flash_stage3d_baseline: enabled<br>gpu_compositing: enabled<br>metal: disabled_off<br>multiple_raster_threads: enabled_on<br>oop_rasterization: disabled_off<br>protected_video_decode: unavailable_off<br>rasterization: enabled<br>skia_renderer: disabled_off<br>surface_control: disabled_off<br>surface_synchronization: enabled_on<br>video_decode: enabled<br>viz_display_compositor: enabled_on<br>viz_hit_test_surface_layer: disabled_off<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.93GB (7.79GB free)|
|Process Argv||
|Screen Reader|no|
|VM|67%|
</details>
<!-- generated by issue reporter -->

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/ptvsd/common/compat.py`
Content:
```
1 # Copyright (c) Microsoft Corporation. All rights reserved.
2 # Licensed under the MIT License. See LICENSE in the project root
3 # for license information.
4 
5 from __future__ import absolute_import, division, print_function, unicode_literals
6 
7 """Python 2/3 compatibility helpers.
8 """
9 
10 import inspect
11 import itertools
12 import sys
13 
14 from ptvsd.common import fmt
15 
16 
17 try:
18     import builtins
19 except ImportError:
20     import __builtin__ as builtins  # noqa
21 
22 try:
23     unicode = builtins.unicode
24     bytes = builtins.str
25 except AttributeError:
26     unicode = builtins.str
27     bytes = builtins.bytes
28 
29 try:
30     xrange = builtins.xrange
31 except AttributeError:
32     xrange = builtins.range
33 
34 try:
35     izip = itertools.izip
36 except AttributeError:
37     izip = builtins.zip
38 
39 try:
40     reload = builtins.reload
41 except AttributeError:
42     from importlib import reload  # noqa
43 
44 try:
45     import queue
46 except ImportError:
47     import Queue as queue  # noqa
48 
49 
50 def force_unicode(s, encoding, errors="strict"):
51     """Converts s to Unicode, using the provided encoding. If s is already Unicode,
52     it is returned as is.
53     """
54     return s.decode(encoding, errors) if isinstance(s, bytes) else unicode(s)
55 
56 
57 def force_bytes(s, encoding, errors="strict"):
58     """Converts s to bytes, using the provided encoding. If s is already bytes,
59     it is returned as is.
60 
61     If errors="strict" and s is bytes, its encoding is verified by decoding it;
62     UnicodeError is raised if it cannot be decoded.
63     """
64     if isinstance(s, unicode):
65         return s.encode(encoding, errors)
66     else:
67         s = bytes(s)
68         if errors == "strict":
69             # Return value ignored - invoked solely for verification.
70             s.decode(encoding, errors)
71         return s
72 
73 
74 def force_str(s, encoding="ascii", errors="strict"):
75     """Converts s to str (which is bytes on Python 2, and unicode on Python 3), using
76     the provided encoding if necessary. If s is already str, it is returned as is.
77 
78     If errors="strict", str is bytes, and s is str, its encoding is verified by decoding
79     it; UnicodeError is raised if it cannot be decoded.
80     """
81     return (force_bytes if str is bytes else force_unicode)(s, encoding, errors)
82 
83 
84 def force_ascii(s, errors="strict"):
85     """Same as force_bytes(s, "ascii", errors)
86     """
87     return force_bytes(s, "ascii", errors)
88 
89 
90 def force_utf8(s, errors="strict"):
91     """Same as force_bytes(s, "utf8", errors)
92     """
93     return force_bytes(s, "utf8", errors)
94 
95 
96 def filename(s, errors="strict"):
97     """Same as force_unicode(s, sys.getfilesystemencoding(), errors)
98     """
99     return force_unicode(s, sys.getfilesystemencoding(), errors)
100 
101 
102 def filename_bytes(s, errors="strict"):
103     """Same as force_bytes(s, sys.getfilesystemencoding(), errors)
104     """
105     return force_bytes(s, sys.getfilesystemencoding(), errors)
106 
107 
108 def filename_str(s, errors="strict"):
109     """Same as force_str(s, sys.getfilesystemencoding(), errors)
110     """
111     return force_str(s, sys.getfilesystemencoding(), errors)
112 
113 
114 def nameof(obj, quote=False):
115     """Returns the most descriptive name of a Python module, class, or function,
116     as a Unicode string
117 
118     If quote=True, name is quoted with repr().
119 
120     Best-effort, but guaranteed to not fail - always returns something.
121     """
122 
123     try:
124         name = obj.__qualname__
125     except Exception:
126         try:
127             name = obj.__name__
128         except Exception:
129             # Fall back to raw repr(), and skip quoting.
130             try:
131                 name = repr(obj)
132             except Exception:
133                 return "<unknown>"
134             else:
135                 quote = False
136 
137     if quote:
138         try:
139             name = repr(name)
140         except Exception:
141             pass
142 
143     return force_unicode(name, "utf-8", "replace")
144 
145 
146 def unicode_repr(obj):
147     """Like repr(), but guarantees that the result is Unicode even on Python 2.
148     """
149     return force_unicode(repr(obj), "ascii")
150 
151 
152 def srcnameof(obj):
153     """Returns the most descriptive name of a Python module, class, or function,
154     including source information (filename and linenumber), if available.
155 
156     Best-effort, but guaranteed to not fail - always returns something.
157     """
158 
159     name = nameof(obj, quote=True)
160 
161     # Get the source information if possible.
162     try:
163         src_file = filename(inspect.getsourcefile(obj), "replace")
164     except Exception:
165         pass
166     else:
167         name += fmt(" (file {0!r}", src_file)
168         try:
169             _, src_lineno = inspect.getsourcelines(obj)
170         except Exception:
171             pass
172         else:
173             name += fmt(", line {0}", src_lineno)
174         name += ")"
175 
176     return name
177
```
--- 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/src/ptvsd/common/compat.py b/src/ptvsd/common/compat.py
--- a/src/ptvsd/common/compat.py
+++ b/src/ptvsd/common/compat.py
@@ -15,9 +15,9 @@
 
 
 try:
-    import builtins
+    import __builtin__ as builtins
 except ImportError:
-    import __builtin__ as builtins  # noqa
+    import builtins
 
 try:
     unicode = builtins.unicode

{"golden_diff": "diff --git a/src/ptvsd/common/compat.py b/src/ptvsd/common/compat.py\n--- a/src/ptvsd/common/compat.py\n+++ b/src/ptvsd/common/compat.py\n@@ -15,9 +15,9 @@\n \n \n try:\n-    import builtins\n+    import __builtin__ as builtins\n except ImportError:\n-    import __builtin__ as builtins  # noqa\n+    import builtins\n \n try:\n     unicode = builtins.unicode\n", "issue": "ptvsd broken on Python 2 if python-future is installed\nIssue Type: <b>Bug</b>\r\n\r\nAfter I installed an interpreter of Python 2.7.16 32bit, an exception is thrown with error message below when I want to switch to the old Python 2.7.16 64bit:\r\n```\r\nE+00000.045: /handling microsoft/vscode-python#1 request \"launch\" from Adapter-1/\r\n             Handler 'launch_request' (file u'c:\\\\Users\\\\linshimeng01\\\\.vscode\\\\extensions\\\\ms-python.python-2019.11.50794\\\\pythonFiles\\\\lib\\\\python\\\\new_ptvsd\\\\no_wheels\\\\ptvsd\\\\launcher/../../ptvsd\\\\launcher\\\\adapter.py', line 35)\r\n             couldn't handle microsoft/vscode-python#1 request \"launch\" from Adapter-1:\r\n\r\n             Traceback (most recent call last):\r\n               File \"c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\common\\messaging.py\", line 763, in _handle\r\n                 result = handler(self)\r\n               File \"c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\launcher\\adapter.py\", line 147, in launch_request\r\n                 debuggee.spawn(process_name, cmdline, cwd, env, redirect_output)\r\n               File \"c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\launcher\\debuggee.py\", line 64, in spawn\r\n                 \"Couldn't spawn debuggee: {0}\\n\\nCommand line:{1!r}\", exc, cmdline\r\n             TypeError: unbound method cant_handle() must be called with Message instance as first argument (got unicode instance instead)\r\n\r\n             Stack where logged:\r\n               File \"C:\\Python27-32\\lib\\threading.py\", line 774, in __bootstrap\r\n                 self.__bootstrap_inner()\r\n               File \"C:\\Python27-32\\lib\\threading.py\", line 801, in __bootstrap_inner\r\n                 self.run()\r\n               File \"C:\\Python27-32\\lib\\threading.py\", line 754, in run\r\n                 self.__target(*self.__args, **self.__kwargs)\r\n               File \"c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\common\\messaging.py\", line 1520, in _run_handlers\r\n                 handler()\r\n               File \"c:\\Users\\linshimeng01\\.vscode\\extensions\\ms-python.python-2019.11.50794\\pythonFiles\\lib\\python\\new_ptvsd\\no_wheels\\ptvsd\\launcher/../../ptvsd\\common\\messaging.py\", line 809, in _handle\r\n                 self.describe(),\r\n```\r\nNow I installed an Python 3 interpreter, and I found the two Python 2 interpreter are all unavailable and throw the same error message above as well when I attempt to run a python file. How can I fix it?\r\n\r\nExtension version: 2019.11.50794\r\nVS Code version: Code 1.40.1 (8795a9889db74563ddd43eb0a897a2384129a619, 2019-11-13T16:49:35.976Z)\r\nOS version: Windows_NT x64 10.0.17763\r\n\r\n<details>\r\n<summary>System Info</summary>\r\n\r\n|Item|Value|\r\n|---|---|\r\n|CPUs|Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz (6 x 2904)|\r\n|GPU Status|2d_canvas: enabled<br>flash_3d: enabled<br>flash_stage3d: enabled<br>flash_stage3d_baseline: enabled<br>gpu_compositing: enabled<br>metal: disabled_off<br>multiple_raster_threads: enabled_on<br>oop_rasterization: disabled_off<br>protected_video_decode: unavailable_off<br>rasterization: enabled<br>skia_renderer: disabled_off<br>surface_control: disabled_off<br>surface_synchronization: enabled_on<br>video_decode: enabled<br>viz_display_compositor: enabled_on<br>viz_hit_test_surface_layer: disabled_off<br>webgl: enabled<br>webgl2: enabled|\r\n|Load (avg)|undefined|\r\n|Memory (System)|15.93GB (7.79GB free)|\r\n|Process Argv||\r\n|Screen Reader|no|\r\n|VM|67%|\r\n</details>\r\n<!-- generated by issue reporter -->\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n\"\"\"Python 2/3 compatibility helpers.\n\"\"\"\n\nimport inspect\nimport itertools\nimport sys\n\nfrom ptvsd.common import fmt\n\n\ntry:\n    import builtins\nexcept ImportError:\n    import __builtin__ as builtins  # noqa\n\ntry:\n    unicode = builtins.unicode\n    bytes = builtins.str\nexcept AttributeError:\n    unicode = builtins.str\n    bytes = builtins.bytes\n\ntry:\n    xrange = builtins.xrange\nexcept AttributeError:\n    xrange = builtins.range\n\ntry:\n    izip = itertools.izip\nexcept AttributeError:\n    izip = builtins.zip\n\ntry:\n    reload = builtins.reload\nexcept AttributeError:\n    from importlib import reload  # noqa\n\ntry:\n    import queue\nexcept ImportError:\n    import Queue as queue  # noqa\n\n\ndef force_unicode(s, encoding, errors=\"strict\"):\n    \"\"\"Converts s to Unicode, using the provided encoding. If s is already Unicode,\n    it is returned as is.\n    \"\"\"\n    return s.decode(encoding, errors) if isinstance(s, bytes) else unicode(s)\n\n\ndef force_bytes(s, encoding, errors=\"strict\"):\n    \"\"\"Converts s to bytes, using the provided encoding. If s is already bytes,\n    it is returned as is.\n\n    If errors=\"strict\" and s is bytes, its encoding is verified by decoding it;\n    UnicodeError is raised if it cannot be decoded.\n    \"\"\"\n    if isinstance(s, unicode):\n        return s.encode(encoding, errors)\n    else:\n        s = bytes(s)\n        if errors == \"strict\":\n            # Return value ignored - invoked solely for verification.\n            s.decode(encoding, errors)\n        return s\n\n\ndef force_str(s, encoding=\"ascii\", errors=\"strict\"):\n    \"\"\"Converts s to str (which is bytes on Python 2, and unicode on Python 3), using\n    the provided encoding if necessary. If s is already str, it is returned as is.\n\n    If errors=\"strict\", str is bytes, and s is str, its encoding is verified by decoding\n    it; UnicodeError is raised if it cannot be decoded.\n    \"\"\"\n    return (force_bytes if str is bytes else force_unicode)(s, encoding, errors)\n\n\ndef force_ascii(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, \"ascii\", errors)\n    \"\"\"\n    return force_bytes(s, \"ascii\", errors)\n\n\ndef force_utf8(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, \"utf8\", errors)\n    \"\"\"\n    return force_bytes(s, \"utf8\", errors)\n\n\ndef filename(s, errors=\"strict\"):\n    \"\"\"Same as force_unicode(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_unicode(s, sys.getfilesystemencoding(), errors)\n\n\ndef filename_bytes(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_bytes(s, sys.getfilesystemencoding(), errors)\n\n\ndef filename_str(s, errors=\"strict\"):\n    \"\"\"Same as force_str(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_str(s, sys.getfilesystemencoding(), errors)\n\n\ndef nameof(obj, quote=False):\n    \"\"\"Returns the most descriptive name of a Python module, class, or function,\n    as a Unicode string\n\n    If quote=True, name is quoted with repr().\n\n    Best-effort, but guaranteed to not fail - always returns something.\n    \"\"\"\n\n    try:\n        name = obj.__qualname__\n    except Exception:\n        try:\n            name = obj.__name__\n        except Exception:\n            # Fall back to raw repr(), and skip quoting.\n            try:\n                name = repr(obj)\n            except Exception:\n                return \"<unknown>\"\n            else:\n                quote = False\n\n    if quote:\n        try:\n            name = repr(name)\n        except Exception:\n            pass\n\n    return force_unicode(name, \"utf-8\", \"replace\")\n\n\ndef unicode_repr(obj):\n    \"\"\"Like repr(), but guarantees that the result is Unicode even on Python 2.\n    \"\"\"\n    return force_unicode(repr(obj), \"ascii\")\n\n\ndef srcnameof(obj):\n    \"\"\"Returns the most descriptive name of a Python module, class, or function,\n    including source information (filename and linenumber), if available.\n\n    Best-effort, but guaranteed to not fail - always returns something.\n    \"\"\"\n\n    name = nameof(obj, quote=True)\n\n    # Get the source information if possible.\n    try:\n        src_file = filename(inspect.getsourcefile(obj), \"replace\")\n    except Exception:\n        pass\n    else:\n        name += fmt(\" (file {0!r}\", src_file)\n        try:\n            _, src_lineno = inspect.getsourcelines(obj)\n        except Exception:\n            pass\n        else:\n            name += fmt(\", line {0}\", src_lineno)\n        name += \")\"\n\n    return name\n", "path": "src/ptvsd/common/compat.py"}], "after_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n\"\"\"Python 2/3 compatibility helpers.\n\"\"\"\n\nimport inspect\nimport itertools\nimport sys\n\nfrom ptvsd.common import fmt\n\n\ntry:\n    import __builtin__ as builtins\nexcept ImportError:\n    import builtins\n\ntry:\n    unicode = builtins.unicode\n    bytes = builtins.str\nexcept AttributeError:\n    unicode = builtins.str\n    bytes = builtins.bytes\n\ntry:\n    xrange = builtins.xrange\nexcept AttributeError:\n    xrange = builtins.range\n\ntry:\n    izip = itertools.izip\nexcept AttributeError:\n    izip = builtins.zip\n\ntry:\n    reload = builtins.reload\nexcept AttributeError:\n    from importlib import reload  # noqa\n\ntry:\n    import queue\nexcept ImportError:\n    import Queue as queue  # noqa\n\n\ndef force_unicode(s, encoding, errors=\"strict\"):\n    \"\"\"Converts s to Unicode, using the provided encoding. If s is already Unicode,\n    it is returned as is.\n    \"\"\"\n    return s.decode(encoding, errors) if isinstance(s, bytes) else unicode(s)\n\n\ndef force_bytes(s, encoding, errors=\"strict\"):\n    \"\"\"Converts s to bytes, using the provided encoding. If s is already bytes,\n    it is returned as is.\n\n    If errors=\"strict\" and s is bytes, its encoding is verified by decoding it;\n    UnicodeError is raised if it cannot be decoded.\n    \"\"\"\n    if isinstance(s, unicode):\n        return s.encode(encoding, errors)\n    else:\n        s = bytes(s)\n        if errors == \"strict\":\n            # Return value ignored - invoked solely for verification.\n            s.decode(encoding, errors)\n        return s\n\n\ndef force_str(s, encoding=\"ascii\", errors=\"strict\"):\n    \"\"\"Converts s to str (which is bytes on Python 2, and unicode on Python 3), using\n    the provided encoding if necessary. If s is already str, it is returned as is.\n\n    If errors=\"strict\", str is bytes, and s is str, its encoding is verified by decoding\n    it; UnicodeError is raised if it cannot be decoded.\n    \"\"\"\n    return (force_bytes if str is bytes else force_unicode)(s, encoding, errors)\n\n\ndef force_ascii(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, \"ascii\", errors)\n    \"\"\"\n    return force_bytes(s, \"ascii\", errors)\n\n\ndef force_utf8(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, \"utf8\", errors)\n    \"\"\"\n    return force_bytes(s, \"utf8\", errors)\n\n\ndef filename(s, errors=\"strict\"):\n    \"\"\"Same as force_unicode(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_unicode(s, sys.getfilesystemencoding(), errors)\n\n\ndef filename_bytes(s, errors=\"strict\"):\n    \"\"\"Same as force_bytes(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_bytes(s, sys.getfilesystemencoding(), errors)\n\n\ndef filename_str(s, errors=\"strict\"):\n    \"\"\"Same as force_str(s, sys.getfilesystemencoding(), errors)\n    \"\"\"\n    return force_str(s, sys.getfilesystemencoding(), errors)\n\n\ndef nameof(obj, quote=False):\n    \"\"\"Returns the most descriptive name of a Python module, class, or function,\n    as a Unicode string\n\n    If quote=True, name is quoted with repr().\n\n    Best-effort, but guaranteed to not fail - always returns something.\n    \"\"\"\n\n    try:\n        name = obj.__qualname__\n    except Exception:\n        try:\n            name = obj.__name__\n        except Exception:\n            # Fall back to raw repr(), and skip quoting.\n            try:\n                name = repr(obj)\n            except Exception:\n                return \"<unknown>\"\n            else:\n                quote = False\n\n    if quote:\n        try:\n            name = repr(name)\n        except Exception:\n            pass\n\n    return force_unicode(name, \"utf-8\", \"replace\")\n\n\ndef unicode_repr(obj):\n    \"\"\"Like repr(), but guarantees that the result is Unicode even on Python 2.\n    \"\"\"\n    return force_unicode(repr(obj), \"ascii\")\n\n\ndef srcnameof(obj):\n    \"\"\"Returns the most descriptive name of a Python module, class, or function,\n    including source information (filename and linenumber), if available.\n\n    Best-effort, but guaranteed to not fail - always returns something.\n    \"\"\"\n\n    name = nameof(obj, quote=True)\n\n    # Get the source information if possible.\n    try:\n        src_file = filename(inspect.getsourcefile(obj), \"replace\")\n    except Exception:\n        pass\n    else:\n        name += fmt(\" (file {0!r}\", src_file)\n        try:\n            _, src_lineno = inspect.getsourcelines(obj)\n        except Exception:\n            pass\n        else:\n            name += fmt(\", line {0}\", src_lineno)\n        name += \")\"\n\n    return name\n", "path": "src/ptvsd/common/compat.py"}]}