We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pyfile adds an additional new line in every line of code
## Environment data

- PTVSD version: master
- OS and version: any
- Python version (& distribution if applicable, e.g. Anaconda): 3.6
- Using VS Code or Visual Studio:

## Actual behavior

code:
```python
@pyfile
def foo():
    print('one')
    print('two')
```
The file generated by pyfile, `foo.py`:
```python
print('one')

print('two')

```

## Expected  behavior

The file generated by pyfile, `foo.py`:
```python
print('one')
print('two')
```

Having the extra blank lines makes it confusing to set breakpoints in tests.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pytests/conftest.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 print_function, with_statement, absolute_import
6 
7 import inspect
8 import pytest
9 import threading
10 import types
11 
12 from .helpers.session import DebugSession
13 
14 
15 @pytest.fixture
16 def daemon():
17     """Provides a factory function for daemon threads. The returned thread is
18     started immediately, and it must not be alive by the time the test returns.
19     """
20 
21     daemons = []
22 
23     def factory(func, name_suffix=''):
24         name = func.__name__ + name_suffix
25         thread = threading.Thread(target=func, name=name)
26         thread.daemon = True
27         daemons.append(thread)
28         thread.start()
29         return thread
30 
31     yield factory
32 
33     for thread in daemons:
34         assert not thread.is_alive()
35 
36 
37 @pytest.fixture
38 def pyfile(request, tmpdir):
39     """A fixture providing a factory function that generates .py files.
40 
41     The returned factory takes a single function with an empty argument list,
42     generates a temporary file that contains the code corresponding to the
43     function body, and returns the full path to the generated file. Idiomatic
44     use is as a decorator, e.g.:
45 
46         @pyfile
47         def script_file():
48             print('fizz')
49             print('buzz')
50 
51     will produce a temporary file named script_file.py containing:
52 
53         print('fizz')
54         print('buzz')
55 
56     and the variable script_file will contain the path to that file.
57 
58     In order for the factory to be able to extract the function body properly,
59     function header ("def") must all be on a single line, with nothing after
60     the colon but whitespace.
61     """
62 
63     def factory(source):
64         assert isinstance(source, types.FunctionType)
65         name = source.__name__
66         source, _ = inspect.getsourcelines(source)
67 
68         # First, find the "def" line.
69         def_lineno = 0
70         for line in source:
71             line = line.strip()
72             if line.startswith('def') and line.endswith(':'):
73                 break
74             def_lineno += 1
75         else:
76             raise ValueError('Failed to locate function header.')
77 
78         # Remove everything up to and including "def".
79         source = source[def_lineno + 1:]
80         assert source
81 
82         # Now we need to adjust indentation. Compute how much the first line of
83         # the body is indented by, then dedent all lines by that amount.
84         line = source[0]
85         indent = len(line) - len(line.lstrip())
86         source = [line[indent:] for line in source]
87         source = '\n'.join(source)
88 
89         tmpfile = tmpdir.join(name + '.py')
90         assert not tmpfile.check()
91         tmpfile.write(source)
92         return tmpfile.strpath
93 
94     return factory
95 
96 
97 @pytest.fixture(params=[
98     'launch', 'attach_socket'  # 'attach_pid'
99 ])
100 def debug_session(request):
101     session = DebugSession(request.param)
102     yield session
103     try:
104         session.wait_for_exit()
105     finally:
106         session.stop()
107 
108 
109
```
--- 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/pytests/conftest.py b/pytests/conftest.py
--- a/pytests/conftest.py
+++ b/pytests/conftest.py
@@ -84,7 +84,7 @@
         line = source[0]
         indent = len(line) - len(line.lstrip())
         source = [line[indent:] for line in source]
-        source = '\n'.join(source)
+        source = ''.join(source)
 
         tmpfile = tmpdir.join(name + '.py')
         assert not tmpfile.check()
@@ -104,5 +104,3 @@
         session.wait_for_exit()
     finally:
         session.stop()
-
-

{"golden_diff": "diff --git a/pytests/conftest.py b/pytests/conftest.py\n--- a/pytests/conftest.py\n+++ b/pytests/conftest.py\n@@ -84,7 +84,7 @@\n         line = source[0]\n         indent = len(line) - len(line.lstrip())\n         source = [line[indent:] for line in source]\n-        source = '\\n'.join(source)\n+        source = ''.join(source)\n \n         tmpfile = tmpdir.join(name + '.py')\n         assert not tmpfile.check()\n@@ -104,5 +104,3 @@\n         session.wait_for_exit()\n     finally:\n         session.stop()\n-\n-\n", "issue": "pyfile adds an additional new line in every line of code\n## Environment data\r\n\r\n- PTVSD version: master\r\n- OS and version: any\r\n- Python version (& distribution if applicable, e.g. Anaconda): 3.6\r\n- Using VS Code or Visual Studio:\r\n\r\n## Actual behavior\r\n\r\ncode:\r\n```python\r\n@pyfile\r\ndef foo():\r\n    print('one')\r\n    print('two')\r\n```\r\nThe file generated by pyfile, `foo.py`:\r\n```python\r\nprint('one')\r\n\r\nprint('two')\r\n\r\n```\r\n\r\n## Expected  behavior\r\n\r\nThe file generated by pyfile, `foo.py`:\r\n```python\r\nprint('one')\r\nprint('two')\r\n```\r\n\r\nHaving the extra blank lines makes it confusing to set breakpoints in tests.\r\n\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 print_function, with_statement, absolute_import\n\nimport inspect\nimport pytest\nimport threading\nimport types\n\nfrom .helpers.session import DebugSession\n\n\n@pytest.fixture\ndef daemon():\n    \"\"\"Provides a factory function for daemon threads. The returned thread is\n    started immediately, and it must not be alive by the time the test returns.\n    \"\"\"\n\n    daemons = []\n\n    def factory(func, name_suffix=''):\n        name = func.__name__ + name_suffix\n        thread = threading.Thread(target=func, name=name)\n        thread.daemon = True\n        daemons.append(thread)\n        thread.start()\n        return thread\n\n    yield factory\n\n    for thread in daemons:\n        assert not thread.is_alive()\n\n\n@pytest.fixture\ndef pyfile(request, tmpdir):\n    \"\"\"A fixture providing a factory function that generates .py files.\n\n    The returned factory takes a single function with an empty argument list,\n    generates a temporary file that contains the code corresponding to the\n    function body, and returns the full path to the generated file. Idiomatic\n    use is as a decorator, e.g.:\n\n        @pyfile\n        def script_file():\n            print('fizz')\n            print('buzz')\n\n    will produce a temporary file named script_file.py containing:\n\n        print('fizz')\n        print('buzz')\n\n    and the variable script_file will contain the path to that file.\n\n    In order for the factory to be able to extract the function body properly,\n    function header (\"def\") must all be on a single line, with nothing after\n    the colon but whitespace.\n    \"\"\"\n\n    def factory(source):\n        assert isinstance(source, types.FunctionType)\n        name = source.__name__\n        source, _ = inspect.getsourcelines(source)\n\n        # First, find the \"def\" line.\n        def_lineno = 0\n        for line in source:\n            line = line.strip()\n            if line.startswith('def') and line.endswith(':'):\n                break\n            def_lineno += 1\n        else:\n            raise ValueError('Failed to locate function header.')\n\n        # Remove everything up to and including \"def\".\n        source = source[def_lineno + 1:]\n        assert source\n\n        # Now we need to adjust indentation. Compute how much the first line of\n        # the body is indented by, then dedent all lines by that amount.\n        line = source[0]\n        indent = len(line) - len(line.lstrip())\n        source = [line[indent:] for line in source]\n        source = '\\n'.join(source)\n\n        tmpfile = tmpdir.join(name + '.py')\n        assert not tmpfile.check()\n        tmpfile.write(source)\n        return tmpfile.strpath\n\n    return factory\n\n\n@pytest.fixture(params=[\n    'launch', 'attach_socket'  # 'attach_pid'\n])\ndef debug_session(request):\n    session = DebugSession(request.param)\n    yield session\n    try:\n        session.wait_for_exit()\n    finally:\n        session.stop()\n\n\n", "path": "pytests/conftest.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 print_function, with_statement, absolute_import\n\nimport inspect\nimport pytest\nimport threading\nimport types\n\nfrom .helpers.session import DebugSession\n\n\n@pytest.fixture\ndef daemon():\n    \"\"\"Provides a factory function for daemon threads. The returned thread is\n    started immediately, and it must not be alive by the time the test returns.\n    \"\"\"\n\n    daemons = []\n\n    def factory(func, name_suffix=''):\n        name = func.__name__ + name_suffix\n        thread = threading.Thread(target=func, name=name)\n        thread.daemon = True\n        daemons.append(thread)\n        thread.start()\n        return thread\n\n    yield factory\n\n    for thread in daemons:\n        assert not thread.is_alive()\n\n\n@pytest.fixture\ndef pyfile(request, tmpdir):\n    \"\"\"A fixture providing a factory function that generates .py files.\n\n    The returned factory takes a single function with an empty argument list,\n    generates a temporary file that contains the code corresponding to the\n    function body, and returns the full path to the generated file. Idiomatic\n    use is as a decorator, e.g.:\n\n        @pyfile\n        def script_file():\n            print('fizz')\n            print('buzz')\n\n    will produce a temporary file named script_file.py containing:\n\n        print('fizz')\n        print('buzz')\n\n    and the variable script_file will contain the path to that file.\n\n    In order for the factory to be able to extract the function body properly,\n    function header (\"def\") must all be on a single line, with nothing after\n    the colon but whitespace.\n    \"\"\"\n\n    def factory(source):\n        assert isinstance(source, types.FunctionType)\n        name = source.__name__\n        source, _ = inspect.getsourcelines(source)\n\n        # First, find the \"def\" line.\n        def_lineno = 0\n        for line in source:\n            line = line.strip()\n            if line.startswith('def') and line.endswith(':'):\n                break\n            def_lineno += 1\n        else:\n            raise ValueError('Failed to locate function header.')\n\n        # Remove everything up to and including \"def\".\n        source = source[def_lineno + 1:]\n        assert source\n\n        # Now we need to adjust indentation. Compute how much the first line of\n        # the body is indented by, then dedent all lines by that amount.\n        line = source[0]\n        indent = len(line) - len(line.lstrip())\n        source = [line[indent:] for line in source]\n        source = ''.join(source)\n\n        tmpfile = tmpdir.join(name + '.py')\n        assert not tmpfile.check()\n        tmpfile.write(source)\n        return tmpfile.strpath\n\n    return factory\n\n\n@pytest.fixture(params=[\n    'launch', 'attach_socket'  # 'attach_pid'\n])\ndef debug_session(request):\n    session = DebugSession(request.param)\n    yield session\n    try:\n        session.wait_for_exit()\n    finally:\n        session.stop()\n", "path": "pytests/conftest.py"}]}