We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
latest 4.3.x (4.3.18-37-g79f86d4c) not picking up conda-build subcommands
From conda-build's test suite:

```
________________________________ test_skeleton_pypi ________________________________
Traceback (most recent call last):
  File "/home/dev/code/conda-build/tests/test_published_examples.py", line 15, in test_skeleton_pypi
    check_call_env(cmd.split())
  File "/home/dev/code/conda-build/conda_build/utils.py", line 670, in check_call_env
    return _func_defaulting_env_to_os_environ(subprocess.check_call, *popenargs, **kwargs)
  File "/home/dev/code/conda-build/conda_build/utils.py", line 666, in _func_defaulting_env_to_os_environ
    return func(_args, **kwargs)
  File "/opt/miniconda/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['conda', 'skeleton', 'pypi', 'pyinstrument']' returned non-zero exit status 2
------------------------------- Captured stderr call -------------------------------
usage: conda [-h] [-V] command ...
conda: error: argument command: invalid choice: u'skeleton' (choose from u'info', u'help', u'list', u'search', u'create', u'install', u'update', u'upgrade', u'remove', u'uninstall', u'config', u'clean', u'package')
```

This seems to happen only with python 2.7, not 3.6: https://travis-ci.org/conda/conda-build/builds/232848688

--- 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/cli/conda_argparse.py`
Content:
```
1 # (c) 2012-2013 Continuum Analytics, Inc. / http://continuum.io
2 # All Rights Reserved
3 #
4 # conda is distributed under the terms of the BSD 3-clause license.
5 # Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.
6 
7 from __future__ import print_function, division, absolute_import, unicode_literals
8 
9 import argparse
10 import os
11 import subprocess
12 import sys
13 
14 from .common import add_parser_help
15 from .find_commands import find_commands, find_executable
16 from ..exceptions import CommandNotFoundError
17 
18 
19 _ARGCOMPLETE_DEBUG = False
20 def debug_argcomplete(msg):
21     # To debug this, replace ttys001 with the fd of the terminal you are using
22     # (use the `tty` command to find this), and set _ARGCOMPLETE_DEBUG above
23     # to True. You can also `export _ARC_DEBUG=1` in the shell you are using
24     # to print debug messages from argcomplete.
25     if _ARGCOMPLETE_DEBUG:
26         f = open('/dev/ttys001', 'w')
27         f.write("\n%s\n" % msg)
28         f.flush()
29 
30 
31 try:
32     import argcomplete
33     argcomplete.CompletionFinder
34 except (ImportError, AttributeError):
35     # On Python 3.3, argcomplete can be an empty namespace package when
36     # we are in the conda-recipes directory.
37     argcomplete = None
38 
39 if argcomplete:
40     class CondaSubprocessCompletionFinder(argcomplete.CompletionFinder):
41         def __call__(self, argument_parser, **kwargs):
42             def call_super():
43                 parent = super(CondaSubprocessCompletionFinder, self)
44                 return parent.__call__(argument_parser, **kwargs)
45 
46             debug_argcomplete("Working")
47 
48             if argument_parser.prog != 'conda':
49                 debug_argcomplete("Argument parser is not conda")
50                 return call_super()
51 
52             environ = os.environ.copy()
53             if 'COMP_LINE' not in environ:
54                 debug_argcomplete("COMP_LINE not in environ")
55                 return call_super()
56 
57             subcommands = find_commands()
58             for subcommand in subcommands:
59                 if 'conda %s' % subcommand in environ['COMP_LINE']:
60                     environ['COMP_LINE'] = environ['COMP_LINE'].replace('conda %s' % subcommand,
61                                                                         'conda-%s' % subcommand)
62                     debug_argcomplete("Using subprocess")
63                     debug_argcomplete(sys.argv)
64                     import pprint
65                     debug_argcomplete(pprint.pformat(environ))
66                     args = [find_executable('conda-%s' % subcommand)]
67                     debug_argcomplete(args)
68                     p = subprocess.Popen(args, env=environ, close_fds=False)
69                     p.communicate()
70                     sys.exit()
71             else:
72                 debug_argcomplete("Not using subprocess")
73                 debug_argcomplete(sys.argv)
74                 debug_argcomplete(argument_parser)
75                 return call_super()
76 
77 class ArgumentParser(argparse.ArgumentParser):
78     def __init__(self, *args, **kwargs):
79         if not kwargs.get('formatter_class'):
80             kwargs['formatter_class'] = argparse.RawDescriptionHelpFormatter
81         if 'add_help' not in kwargs:
82             add_custom_help = True
83             kwargs['add_help'] = False
84         else:
85             add_custom_help = False
86         super(ArgumentParser, self).__init__(*args, **kwargs)
87 
88         if add_custom_help:
89             add_parser_help(self)
90 
91         if self.description:
92             self.description += "\n\nOptions:\n"
93 
94     def _get_action_from_name(self, name):
95         """Given a name, get the Action instance registered with this parser.
96         If only it were made available in the ArgumentError object. It is
97         passed as it's first arg...
98         """
99         container = self._actions
100         if name is None:
101             return None
102         for action in container:
103             if '/'.join(action.option_strings) == name:
104                 return action
105             elif action.metavar == name:
106                 return action
107             elif action.dest == name:
108                 return action
109 
110     def error(self, message):
111         import re
112         import subprocess
113         from .find_commands import find_executable
114 
115         exc = sys.exc_info()[1]
116         if exc:
117             # this is incredibly lame, but argparse stupidly does not expose
118             # reasonable hooks for customizing error handling
119             if hasattr(exc, 'argument_name'):
120                 argument = self._get_action_from_name(exc.argument_name)
121             else:
122                 argument = None
123             if argument and argument.dest == "cmd":
124                 m = re.compile(r"invalid choice: '([\w\-]+)'").match(exc.message)
125                 if m:
126                     cmd = m.group(1)
127                     executable = find_executable('conda-' + cmd)
128                     if not executable:
129                         raise CommandNotFoundError(cmd)
130 
131                     args = [find_executable('conda-' + cmd)]
132                     args.extend(sys.argv[2:])
133                     p = subprocess.Popen(args)
134                     try:
135                         p.communicate()
136                     except KeyboardInterrupt:
137                         p.wait()
138                     finally:
139                         sys.exit(p.returncode)
140 
141         super(ArgumentParser, self).error(message)
142 
143     def print_help(self):
144         super(ArgumentParser, self).print_help()
145 
146         if self.prog == 'conda' and sys.argv[1:] in ([], ['help'], ['-h'], ['--help']):
147             print("""
148 other commands, such as "conda build", are avaialble when additional conda
149 packages (e.g. conda-build) are installed
150 """)
151 
152     def parse_args(self, *args, **kwargs):
153         if argcomplete:
154             CondaSubprocessCompletionFinder()(self)
155 
156         return super(ArgumentParser, self).parse_args(*args, **kwargs)
157
```
--- 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/cli/conda_argparse.py b/conda/cli/conda_argparse.py
--- a/conda/cli/conda_argparse.py
+++ b/conda/cli/conda_argparse.py
@@ -121,7 +121,7 @@
             else:
                 argument = None
             if argument and argument.dest == "cmd":
-                m = re.compile(r"invalid choice: '([\w\-]+)'").match(exc.message)
+                m = re.compile(r"invalid choice: u?'([\w\-]+)'").match(exc.message)
                 if m:
                     cmd = m.group(1)
                     executable = find_executable('conda-' + cmd)

{"golden_diff": "diff --git a/conda/cli/conda_argparse.py b/conda/cli/conda_argparse.py\n--- a/conda/cli/conda_argparse.py\n+++ b/conda/cli/conda_argparse.py\n@@ -121,7 +121,7 @@\n             else:\n                 argument = None\n             if argument and argument.dest == \"cmd\":\n-                m = re.compile(r\"invalid choice: '([\\w\\-]+)'\").match(exc.message)\n+                m = re.compile(r\"invalid choice: u?'([\\w\\-]+)'\").match(exc.message)\n                 if m:\n                     cmd = m.group(1)\n                     executable = find_executable('conda-' + cmd)\n", "issue": "latest 4.3.x (4.3.18-37-g79f86d4c) not picking up conda-build subcommands\nFrom conda-build's test suite:\r\n\r\n```\r\n________________________________ test_skeleton_pypi ________________________________\r\nTraceback (most recent call last):\r\n  File \"/home/dev/code/conda-build/tests/test_published_examples.py\", line 15, in test_skeleton_pypi\r\n    check_call_env(cmd.split())\r\n  File \"/home/dev/code/conda-build/conda_build/utils.py\", line 670, in check_call_env\r\n    return _func_defaulting_env_to_os_environ(subprocess.check_call, *popenargs, **kwargs)\r\n  File \"/home/dev/code/conda-build/conda_build/utils.py\", line 666, in _func_defaulting_env_to_os_environ\r\n    return func(_args, **kwargs)\r\n  File \"/opt/miniconda/lib/python2.7/subprocess.py\", line 541, in check_call\r\n    raise CalledProcessError(retcode, cmd)\r\nCalledProcessError: Command '['conda', 'skeleton', 'pypi', 'pyinstrument']' returned non-zero exit status 2\r\n------------------------------- Captured stderr call -------------------------------\r\nusage: conda [-h] [-V] command ...\r\nconda: error: argument command: invalid choice: u'skeleton' (choose from u'info', u'help', u'list', u'search', u'create', u'install', u'update', u'upgrade', u'remove', u'uninstall', u'config', u'clean', u'package')\r\n```\r\n\r\nThis seems to happen only with python 2.7, not 3.6: https://travis-ci.org/conda/conda-build/builds/232848688\n", "before_files": [{"content": "# (c) 2012-2013 Continuum Analytics, Inc. / http://continuum.io\n# All Rights Reserved\n#\n# conda is distributed under the terms of the BSD 3-clause license.\n# Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.\n\nfrom __future__ import print_function, division, absolute_import, unicode_literals\n\nimport argparse\nimport os\nimport subprocess\nimport sys\n\nfrom .common import add_parser_help\nfrom .find_commands import find_commands, find_executable\nfrom ..exceptions import CommandNotFoundError\n\n\n_ARGCOMPLETE_DEBUG = False\ndef debug_argcomplete(msg):\n    # To debug this, replace ttys001 with the fd of the terminal you are using\n    # (use the `tty` command to find this), and set _ARGCOMPLETE_DEBUG above\n    # to True. You can also `export _ARC_DEBUG=1` in the shell you are using\n    # to print debug messages from argcomplete.\n    if _ARGCOMPLETE_DEBUG:\n        f = open('/dev/ttys001', 'w')\n        f.write(\"\\n%s\\n\" % msg)\n        f.flush()\n\n\ntry:\n    import argcomplete\n    argcomplete.CompletionFinder\nexcept (ImportError, AttributeError):\n    # On Python 3.3, argcomplete can be an empty namespace package when\n    # we are in the conda-recipes directory.\n    argcomplete = None\n\nif argcomplete:\n    class CondaSubprocessCompletionFinder(argcomplete.CompletionFinder):\n        def __call__(self, argument_parser, **kwargs):\n            def call_super():\n                parent = super(CondaSubprocessCompletionFinder, self)\n                return parent.__call__(argument_parser, **kwargs)\n\n            debug_argcomplete(\"Working\")\n\n            if argument_parser.prog != 'conda':\n                debug_argcomplete(\"Argument parser is not conda\")\n                return call_super()\n\n            environ = os.environ.copy()\n            if 'COMP_LINE' not in environ:\n                debug_argcomplete(\"COMP_LINE not in environ\")\n                return call_super()\n\n            subcommands = find_commands()\n            for subcommand in subcommands:\n                if 'conda %s' % subcommand in environ['COMP_LINE']:\n                    environ['COMP_LINE'] = environ['COMP_LINE'].replace('conda %s' % subcommand,\n                                                                        'conda-%s' % subcommand)\n                    debug_argcomplete(\"Using subprocess\")\n                    debug_argcomplete(sys.argv)\n                    import pprint\n                    debug_argcomplete(pprint.pformat(environ))\n                    args = [find_executable('conda-%s' % subcommand)]\n                    debug_argcomplete(args)\n                    p = subprocess.Popen(args, env=environ, close_fds=False)\n                    p.communicate()\n                    sys.exit()\n            else:\n                debug_argcomplete(\"Not using subprocess\")\n                debug_argcomplete(sys.argv)\n                debug_argcomplete(argument_parser)\n                return call_super()\n\nclass ArgumentParser(argparse.ArgumentParser):\n    def __init__(self, *args, **kwargs):\n        if not kwargs.get('formatter_class'):\n            kwargs['formatter_class'] = argparse.RawDescriptionHelpFormatter\n        if 'add_help' not in kwargs:\n            add_custom_help = True\n            kwargs['add_help'] = False\n        else:\n            add_custom_help = False\n        super(ArgumentParser, self).__init__(*args, **kwargs)\n\n        if add_custom_help:\n            add_parser_help(self)\n\n        if self.description:\n            self.description += \"\\n\\nOptions:\\n\"\n\n    def _get_action_from_name(self, name):\n        \"\"\"Given a name, get the Action instance registered with this parser.\n        If only it were made available in the ArgumentError object. It is\n        passed as it's first arg...\n        \"\"\"\n        container = self._actions\n        if name is None:\n            return None\n        for action in container:\n            if '/'.join(action.option_strings) == name:\n                return action\n            elif action.metavar == name:\n                return action\n            elif action.dest == name:\n                return action\n\n    def error(self, message):\n        import re\n        import subprocess\n        from .find_commands import find_executable\n\n        exc = sys.exc_info()[1]\n        if exc:\n            # this is incredibly lame, but argparse stupidly does not expose\n            # reasonable hooks for customizing error handling\n            if hasattr(exc, 'argument_name'):\n                argument = self._get_action_from_name(exc.argument_name)\n            else:\n                argument = None\n            if argument and argument.dest == \"cmd\":\n                m = re.compile(r\"invalid choice: '([\\w\\-]+)'\").match(exc.message)\n                if m:\n                    cmd = m.group(1)\n                    executable = find_executable('conda-' + cmd)\n                    if not executable:\n                        raise CommandNotFoundError(cmd)\n\n                    args = [find_executable('conda-' + cmd)]\n                    args.extend(sys.argv[2:])\n                    p = subprocess.Popen(args)\n                    try:\n                        p.communicate()\n                    except KeyboardInterrupt:\n                        p.wait()\n                    finally:\n                        sys.exit(p.returncode)\n\n        super(ArgumentParser, self).error(message)\n\n    def print_help(self):\n        super(ArgumentParser, self).print_help()\n\n        if self.prog == 'conda' and sys.argv[1:] in ([], ['help'], ['-h'], ['--help']):\n            print(\"\"\"\nother commands, such as \"conda build\", are avaialble when additional conda\npackages (e.g. conda-build) are installed\n\"\"\")\n\n    def parse_args(self, *args, **kwargs):\n        if argcomplete:\n            CondaSubprocessCompletionFinder()(self)\n\n        return super(ArgumentParser, self).parse_args(*args, **kwargs)\n", "path": "conda/cli/conda_argparse.py"}], "after_files": [{"content": "# (c) 2012-2013 Continuum Analytics, Inc. / http://continuum.io\n# All Rights Reserved\n#\n# conda is distributed under the terms of the BSD 3-clause license.\n# Consult LICENSE.txt or http://opensource.org/licenses/BSD-3-Clause.\n\nfrom __future__ import print_function, division, absolute_import, unicode_literals\n\nimport argparse\nimport os\nimport subprocess\nimport sys\n\nfrom .common import add_parser_help\nfrom .find_commands import find_commands, find_executable\nfrom ..exceptions import CommandNotFoundError\n\n\n_ARGCOMPLETE_DEBUG = False\ndef debug_argcomplete(msg):\n    # To debug this, replace ttys001 with the fd of the terminal you are using\n    # (use the `tty` command to find this), and set _ARGCOMPLETE_DEBUG above\n    # to True. You can also `export _ARC_DEBUG=1` in the shell you are using\n    # to print debug messages from argcomplete.\n    if _ARGCOMPLETE_DEBUG:\n        f = open('/dev/ttys001', 'w')\n        f.write(\"\\n%s\\n\" % msg)\n        f.flush()\n\n\ntry:\n    import argcomplete\n    argcomplete.CompletionFinder\nexcept (ImportError, AttributeError):\n    # On Python 3.3, argcomplete can be an empty namespace package when\n    # we are in the conda-recipes directory.\n    argcomplete = None\n\nif argcomplete:\n    class CondaSubprocessCompletionFinder(argcomplete.CompletionFinder):\n        def __call__(self, argument_parser, **kwargs):\n            def call_super():\n                parent = super(CondaSubprocessCompletionFinder, self)\n                return parent.__call__(argument_parser, **kwargs)\n\n            debug_argcomplete(\"Working\")\n\n            if argument_parser.prog != 'conda':\n                debug_argcomplete(\"Argument parser is not conda\")\n                return call_super()\n\n            environ = os.environ.copy()\n            if 'COMP_LINE' not in environ:\n                debug_argcomplete(\"COMP_LINE not in environ\")\n                return call_super()\n\n            subcommands = find_commands()\n            for subcommand in subcommands:\n                if 'conda %s' % subcommand in environ['COMP_LINE']:\n                    environ['COMP_LINE'] = environ['COMP_LINE'].replace('conda %s' % subcommand,\n                                                                        'conda-%s' % subcommand)\n                    debug_argcomplete(\"Using subprocess\")\n                    debug_argcomplete(sys.argv)\n                    import pprint\n                    debug_argcomplete(pprint.pformat(environ))\n                    args = [find_executable('conda-%s' % subcommand)]\n                    debug_argcomplete(args)\n                    p = subprocess.Popen(args, env=environ, close_fds=False)\n                    p.communicate()\n                    sys.exit()\n            else:\n                debug_argcomplete(\"Not using subprocess\")\n                debug_argcomplete(sys.argv)\n                debug_argcomplete(argument_parser)\n                return call_super()\n\nclass ArgumentParser(argparse.ArgumentParser):\n    def __init__(self, *args, **kwargs):\n        if not kwargs.get('formatter_class'):\n            kwargs['formatter_class'] = argparse.RawDescriptionHelpFormatter\n        if 'add_help' not in kwargs:\n            add_custom_help = True\n            kwargs['add_help'] = False\n        else:\n            add_custom_help = False\n        super(ArgumentParser, self).__init__(*args, **kwargs)\n\n        if add_custom_help:\n            add_parser_help(self)\n\n        if self.description:\n            self.description += \"\\n\\nOptions:\\n\"\n\n    def _get_action_from_name(self, name):\n        \"\"\"Given a name, get the Action instance registered with this parser.\n        If only it were made available in the ArgumentError object. It is\n        passed as it's first arg...\n        \"\"\"\n        container = self._actions\n        if name is None:\n            return None\n        for action in container:\n            if '/'.join(action.option_strings) == name:\n                return action\n            elif action.metavar == name:\n                return action\n            elif action.dest == name:\n                return action\n\n    def error(self, message):\n        import re\n        import subprocess\n        from .find_commands import find_executable\n\n        exc = sys.exc_info()[1]\n        if exc:\n            # this is incredibly lame, but argparse stupidly does not expose\n            # reasonable hooks for customizing error handling\n            if hasattr(exc, 'argument_name'):\n                argument = self._get_action_from_name(exc.argument_name)\n            else:\n                argument = None\n            if argument and argument.dest == \"cmd\":\n                m = re.compile(r\"invalid choice: u?'([\\w\\-]+)'\").match(exc.message)\n                if m:\n                    cmd = m.group(1)\n                    executable = find_executable('conda-' + cmd)\n                    if not executable:\n                        raise CommandNotFoundError(cmd)\n\n                    args = [find_executable('conda-' + cmd)]\n                    args.extend(sys.argv[2:])\n                    p = subprocess.Popen(args)\n                    try:\n                        p.communicate()\n                    except KeyboardInterrupt:\n                        p.wait()\n                    finally:\n                        sys.exit(p.returncode)\n\n        super(ArgumentParser, self).error(message)\n\n    def print_help(self):\n        super(ArgumentParser, self).print_help()\n\n        if self.prog == 'conda' and sys.argv[1:] in ([], ['help'], ['-h'], ['--help']):\n            print(\"\"\"\nother commands, such as \"conda build\", are avaialble when additional conda\npackages (e.g. conda-build) are installed\n\"\"\")\n\n    def parse_args(self, *args, **kwargs):\n        if argcomplete:\n            CondaSubprocessCompletionFinder()(self)\n\n        return super(ArgumentParser, self).parse_args(*args, **kwargs)\n", "path": "conda/cli/conda_argparse.py"}]}