We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Not compatible with ruamel.yaml 0.16
Fails with,

```
Traceback (most recent call last):

  File "/home/travis/miniconda/bin/conda-smithy", line 10, in <module>

    sys.exit(main())

  File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py", line 470, in main

    args.subcommand_func(args)

  File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py", line 217, in __call__

    args.feedstock_directory, owner, repo

  File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/ci_register.py", line 351, in travis_token_update_conda_forge_config

    ] = travis_encrypt_binstar_token(slug, item)

  File "/home/travis/miniconda/lib/python3.7/contextlib.py", line 119, in __exit__

    next(self.gen)

  File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/utils.py", line 92, in update_conda_forge_config

    fh.write(yaml.dump(code))

  File "/home/travis/miniconda/lib/python3.7/site-packages/ruamel/yaml/main.py", line 448, in dump

    raise TypeError('Need a stream argument when not dumping from context manager')

TypeError: Need a stream argument when not dumping from context manager
```

cc @ocefpaf, @scopatz

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_smithy/utils.py`
Content:
```
1 import shutil
2 import tempfile
3 import jinja2
4 import datetime
5 import time
6 import os
7 import sys
8 from collections import defaultdict
9 from contextlib import contextmanager
10 
11 import ruamel.yaml
12 
13 
14 # define global yaml API
15 # roundrip-loader and allowing duplicate keys
16 # for handling # [filter] / # [not filter]
17 yaml = ruamel.yaml.YAML(typ="rt")
18 yaml.allow_duplicate_keys = True
19 
20 
21 @contextmanager
22 def tmp_directory():
23     tmp_dir = tempfile.mkdtemp("_recipe")
24     yield tmp_dir
25     shutil.rmtree(tmp_dir)
26 
27 
28 class NullUndefined(jinja2.Undefined):
29     def __unicode__(self):
30         return self._undefined_name
31 
32     def __getattr__(self, name):
33         return "{}.{}".format(self, name)
34 
35     def __getitem__(self, name):
36         return '{}["{}"]'.format(self, name)
37 
38 
39 class MockOS(dict):
40     def __init__(self):
41         self.environ = defaultdict(lambda: "")
42         self.sep = "/"
43 
44 
45 def render_meta_yaml(text):
46     env = jinja2.Environment(undefined=NullUndefined)
47 
48     # stub out cb3 jinja2 functions - they are not important for linting
49     #    if we don't stub them out, the ruamel.yaml load fails to interpret them
50     #    we can't just use conda-build's api.render functionality, because it would apply selectors
51     env.globals.update(
52         dict(
53             compiler=lambda x: x + "_compiler_stub",
54             pin_subpackage=lambda *args, **kwargs: "subpackage_stub",
55             pin_compatible=lambda *args, **kwargs: "compatible_pin_stub",
56             cdt=lambda *args, **kwargs: "cdt_stub",
57             load_file_regex=lambda *args, **kwargs: defaultdict(lambda: ""),
58             datetime=datetime,
59             time=time,
60             target_platform="linux-64",
61         )
62     )
63     mockos = MockOS()
64     py_ver = "3.7"
65     context = {"os": mockos, "environ": mockos.environ, "PY_VER": py_ver}
66     content = env.from_string(text).render(context)
67     return content
68 
69 
70 @contextmanager
71 def update_conda_forge_config(feedstock_directory):
72     """Utility method used to update conda forge configuration files
73 
74     Uage:
75     >>> with update_conda_forge_config(somepath) as cfg:
76     ...     cfg['foo'] = 'bar'
77     """
78     forge_yaml = os.path.join(feedstock_directory, "conda-forge.yml")
79     if os.path.exists(forge_yaml):
80         with open(forge_yaml, "r") as fh:
81             code = yaml.load(fh)
82     else:
83         code = {}
84 
85     # Code could come in as an empty list.
86     if not code:
87         code = {}
88 
89     yield code
90 
91     with open(forge_yaml, "w") as fh:
92         fh.write(yaml.dump(code))
93
```
--- 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/conda_smithy/utils.py b/conda_smithy/utils.py
--- a/conda_smithy/utils.py
+++ b/conda_smithy/utils.py
@@ -88,5 +88,4 @@
 
     yield code
 
-    with open(forge_yaml, "w") as fh:
-        fh.write(yaml.dump(code))
+    yaml.dump(code, forge_yaml)

{"golden_diff": "diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py\n--- a/conda_smithy/utils.py\n+++ b/conda_smithy/utils.py\n@@ -88,5 +88,4 @@\n \n     yield code\n \n-    with open(forge_yaml, \"w\") as fh:\n-        fh.write(yaml.dump(code))\n+    yaml.dump(code, forge_yaml)\n", "issue": "Not compatible with ruamel.yaml 0.16\nFails with,\r\n\r\n```\r\nTraceback (most recent call last):\r\n\r\n  File \"/home/travis/miniconda/bin/conda-smithy\", line 10, in <module>\r\n\r\n    sys.exit(main())\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py\", line 470, in main\r\n\r\n    args.subcommand_func(args)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py\", line 217, in __call__\r\n\r\n    args.feedstock_directory, owner, repo\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/ci_register.py\", line 351, in travis_token_update_conda_forge_config\r\n\r\n    ] = travis_encrypt_binstar_token(slug, item)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/contextlib.py\", line 119, in __exit__\r\n\r\n    next(self.gen)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/utils.py\", line 92, in update_conda_forge_config\r\n\r\n    fh.write(yaml.dump(code))\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/ruamel/yaml/main.py\", line 448, in dump\r\n\r\n    raise TypeError('Need a stream argument when not dumping from context manager')\r\n\r\nTypeError: Need a stream argument when not dumping from context manager\r\n```\r\n\r\ncc @ocefpaf, @scopatz\n", "before_files": [{"content": "import shutil\nimport tempfile\nimport jinja2\nimport datetime\nimport time\nimport os\nimport sys\nfrom collections import defaultdict\nfrom contextlib import contextmanager\n\nimport ruamel.yaml\n\n\n# define global yaml API\n# roundrip-loader and allowing duplicate keys\n# for handling # [filter] / # [not filter]\nyaml = ruamel.yaml.YAML(typ=\"rt\")\nyaml.allow_duplicate_keys = True\n\n\n@contextmanager\ndef tmp_directory():\n    tmp_dir = tempfile.mkdtemp(\"_recipe\")\n    yield tmp_dir\n    shutil.rmtree(tmp_dir)\n\n\nclass NullUndefined(jinja2.Undefined):\n    def __unicode__(self):\n        return self._undefined_name\n\n    def __getattr__(self, name):\n        return \"{}.{}\".format(self, name)\n\n    def __getitem__(self, name):\n        return '{}[\"{}\"]'.format(self, name)\n\n\nclass MockOS(dict):\n    def __init__(self):\n        self.environ = defaultdict(lambda: \"\")\n        self.sep = \"/\"\n\n\ndef render_meta_yaml(text):\n    env = jinja2.Environment(undefined=NullUndefined)\n\n    # stub out cb3 jinja2 functions - they are not important for linting\n    #    if we don't stub them out, the ruamel.yaml load fails to interpret them\n    #    we can't just use conda-build's api.render functionality, because it would apply selectors\n    env.globals.update(\n        dict(\n            compiler=lambda x: x + \"_compiler_stub\",\n            pin_subpackage=lambda *args, **kwargs: \"subpackage_stub\",\n            pin_compatible=lambda *args, **kwargs: \"compatible_pin_stub\",\n            cdt=lambda *args, **kwargs: \"cdt_stub\",\n            load_file_regex=lambda *args, **kwargs: defaultdict(lambda: \"\"),\n            datetime=datetime,\n            time=time,\n            target_platform=\"linux-64\",\n        )\n    )\n    mockos = MockOS()\n    py_ver = \"3.7\"\n    context = {\"os\": mockos, \"environ\": mockos.environ, \"PY_VER\": py_ver}\n    content = env.from_string(text).render(context)\n    return content\n\n\n@contextmanager\ndef update_conda_forge_config(feedstock_directory):\n    \"\"\"Utility method used to update conda forge configuration files\n\n    Uage:\n    >>> with update_conda_forge_config(somepath) as cfg:\n    ...     cfg['foo'] = 'bar'\n    \"\"\"\n    forge_yaml = os.path.join(feedstock_directory, \"conda-forge.yml\")\n    if os.path.exists(forge_yaml):\n        with open(forge_yaml, \"r\") as fh:\n            code = yaml.load(fh)\n    else:\n        code = {}\n\n    # Code could come in as an empty list.\n    if not code:\n        code = {}\n\n    yield code\n\n    with open(forge_yaml, \"w\") as fh:\n        fh.write(yaml.dump(code))\n", "path": "conda_smithy/utils.py"}], "after_files": [{"content": "import shutil\nimport tempfile\nimport jinja2\nimport datetime\nimport time\nimport os\nimport sys\nfrom collections import defaultdict\nfrom contextlib import contextmanager\n\nimport ruamel.yaml\n\n\n# define global yaml API\n# roundrip-loader and allowing duplicate keys\n# for handling # [filter] / # [not filter]\nyaml = ruamel.yaml.YAML(typ=\"rt\")\nyaml.allow_duplicate_keys = True\n\n\n@contextmanager\ndef tmp_directory():\n    tmp_dir = tempfile.mkdtemp(\"_recipe\")\n    yield tmp_dir\n    shutil.rmtree(tmp_dir)\n\n\nclass NullUndefined(jinja2.Undefined):\n    def __unicode__(self):\n        return self._undefined_name\n\n    def __getattr__(self, name):\n        return \"{}.{}\".format(self, name)\n\n    def __getitem__(self, name):\n        return '{}[\"{}\"]'.format(self, name)\n\n\nclass MockOS(dict):\n    def __init__(self):\n        self.environ = defaultdict(lambda: \"\")\n        self.sep = \"/\"\n\n\ndef render_meta_yaml(text):\n    env = jinja2.Environment(undefined=NullUndefined)\n\n    # stub out cb3 jinja2 functions - they are not important for linting\n    #    if we don't stub them out, the ruamel.yaml load fails to interpret them\n    #    we can't just use conda-build's api.render functionality, because it would apply selectors\n    env.globals.update(\n        dict(\n            compiler=lambda x: x + \"_compiler_stub\",\n            pin_subpackage=lambda *args, **kwargs: \"subpackage_stub\",\n            pin_compatible=lambda *args, **kwargs: \"compatible_pin_stub\",\n            cdt=lambda *args, **kwargs: \"cdt_stub\",\n            load_file_regex=lambda *args, **kwargs: defaultdict(lambda: \"\"),\n            datetime=datetime,\n            time=time,\n            target_platform=\"linux-64\",\n        )\n    )\n    mockos = MockOS()\n    py_ver = \"3.7\"\n    context = {\"os\": mockos, \"environ\": mockos.environ, \"PY_VER\": py_ver}\n    content = env.from_string(text).render(context)\n    return content\n\n\n@contextmanager\ndef update_conda_forge_config(feedstock_directory):\n    \"\"\"Utility method used to update conda forge configuration files\n\n    Uage:\n    >>> with update_conda_forge_config(somepath) as cfg:\n    ...     cfg['foo'] = 'bar'\n    \"\"\"\n    forge_yaml = os.path.join(feedstock_directory, \"conda-forge.yml\")\n    if os.path.exists(forge_yaml):\n        with open(forge_yaml, \"r\") as fh:\n            code = yaml.load(fh)\n    else:\n        code = {}\n\n    # Code could come in as an empty list.\n    if not code:\n        code = {}\n\n    yield code\n\n    yaml.dump(code, forge_yaml)\n", "path": "conda_smithy/utils.py"}]}