We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
find_cmd test failure on Windows
I think this is caused by #3301. The [Windows implementation of find_cmd](https://github.com/ipython/ipython/blob/master/IPython/utils/_process_win32.py#L74) expects a command name without an extension, but the test now uses 'python.exe'.

I think that 'python.exe' is a valid command on Windows, so I think we should modify `find_cmd` to allow passing a command with an extension. Alternatively, we could modify the test to strip the extension.

```
======================================================================
ERROR: Make sure we find sys.exectable for python.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "S:\Users\slave\Jenkins\shiningpanda\jobs\d5f643a2\virtualenvs\ff035a1d\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "S:\Users\slave\Jenkins\shiningpanda\jobs\d5f643a2\virtualenvs\ff035a1d\lib\site-packages\ipython-1.0.dev-py2.7.egg\IPython\utils\tests\test_process.py", line 36, in test_find_cmd_python
    nt.assert_equal(find_cmd(python), sys.executable)
  File "S:\Users\slave\Jenkins\shiningpanda\jobs\d5f643a2\virtualenvs\ff035a1d\lib\site-packages\ipython-1.0.dev-py2.7.egg\IPython\utils\process.py", line 67, in find_cmd
    raise FindCmdError('command could not be found: %s' % cmd)
FindCmdError: command could not be found: python.exe
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/utils/_process_win32.py`
Content:
```
1 """Windows-specific implementation of process utilities.
2 
3 This file is only meant to be imported by process.py, not by end-users.
4 """
5 
6 #-----------------------------------------------------------------------------
7 #  Copyright (C) 2010-2011  The IPython Development Team
8 #
9 #  Distributed under the terms of the BSD License.  The full license is in
10 #  the file COPYING, distributed as part of this software.
11 #-----------------------------------------------------------------------------
12 
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16 from __future__ import print_function
17 
18 # stdlib
19 import os
20 import sys
21 import ctypes
22 import msvcrt
23 
24 from ctypes import c_int, POINTER
25 from ctypes.wintypes import LPCWSTR, HLOCAL
26 from subprocess import STDOUT
27 
28 # our own imports
29 from ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split
30 from . import py3compat
31 from .encoding import DEFAULT_ENCODING
32 
33 #-----------------------------------------------------------------------------
34 # Function definitions
35 #-----------------------------------------------------------------------------
36 
37 class AvoidUNCPath(object):
38     """A context manager to protect command execution from UNC paths.
39 
40     In the Win32 API, commands can't be invoked with the cwd being a UNC path.
41     This context manager temporarily changes directory to the 'C:' drive on
42     entering, and restores the original working directory on exit.
43 
44     The context manager returns the starting working directory *if* it made a
45     change and None otherwise, so that users can apply the necessary adjustment
46     to their system calls in the event of a change.
47 
48     Example
49     -------
50     ::
51         cmd = 'dir'
52         with AvoidUNCPath() as path:
53             if path is not None:
54                 cmd = '"pushd %s &&"%s' % (path, cmd)
55             os.system(cmd)
56     """
57     def __enter__(self):
58         self.path = os.getcwdu()
59         self.is_unc_path = self.path.startswith(r"\\")
60         if self.is_unc_path:
61             # change to c drive (as cmd.exe cannot handle UNC addresses)
62             os.chdir("C:")
63             return self.path
64         else:
65             # We return None to signal that there was no change in the working
66             # directory
67             return None
68 
69     def __exit__(self, exc_type, exc_value, traceback):
70         if self.is_unc_path:
71             os.chdir(self.path)
72 
73 
74 def _find_cmd(cmd):
75     """Find the full path to a .bat or .exe using the win32api module."""
76     try:
77         from win32api import SearchPath
78     except ImportError:
79         raise ImportError('you need to have pywin32 installed for this to work')
80     else:
81         PATH = os.environ['PATH']
82         extensions = ['.exe', '.com', '.bat', '.py']
83         path = None
84         for ext in extensions:
85             try:
86                 path = SearchPath(PATH, cmd + ext)[0]
87             except:
88                 pass
89         if path is None:
90             raise OSError("command %r not found" % cmd)
91         else:
92             return path
93 
94 
95 def _system_body(p):
96     """Callback for _system."""
97     enc = DEFAULT_ENCODING
98     for line in read_no_interrupt(p.stdout).splitlines():
99         line = line.decode(enc, 'replace')
100         print(line, file=sys.stdout)
101     for line in read_no_interrupt(p.stderr).splitlines():
102         line = line.decode(enc, 'replace')
103         print(line, file=sys.stderr)
104 
105     # Wait to finish for returncode
106     return p.wait()
107 
108 
109 def system(cmd):
110     """Win32 version of os.system() that works with network shares.
111 
112     Note that this implementation returns None, as meant for use in IPython.
113 
114     Parameters
115     ----------
116     cmd : str
117       A command to be executed in the system shell.
118 
119     Returns
120     -------
121     None : we explicitly do NOT return the subprocess status code, as this
122     utility is meant to be used extensively in IPython, where any return value
123     would trigger :func:`sys.displayhook` calls.
124     """
125     # The controller provides interactivity with both
126     # stdin and stdout
127     #import _process_win32_controller
128     #_process_win32_controller.system(cmd)
129 
130     with AvoidUNCPath() as path:
131         if path is not None:
132             cmd = '"pushd %s &&"%s' % (path, cmd)
133         return process_handler(cmd, _system_body)
134 
135 def getoutput(cmd):
136     """Return standard output of executing cmd in a shell.
137 
138     Accepts the same arguments as os.system().
139 
140     Parameters
141     ----------
142     cmd : str
143       A command to be executed in the system shell.
144 
145     Returns
146     -------
147     stdout : str
148     """
149 
150     with AvoidUNCPath() as path:
151         if path is not None:
152             cmd = '"pushd %s &&"%s' % (path, cmd)
153         out = process_handler(cmd, lambda p: p.communicate()[0], STDOUT)
154 
155     if out is None:
156         out = b''
157     return py3compat.bytes_to_str(out)
158 
159 try:
160     CommandLineToArgvW = ctypes.windll.shell32.CommandLineToArgvW
161     CommandLineToArgvW.arg_types = [LPCWSTR, POINTER(c_int)]
162     CommandLineToArgvW.restype = POINTER(LPCWSTR)
163     LocalFree = ctypes.windll.kernel32.LocalFree
164     LocalFree.res_type = HLOCAL
165     LocalFree.arg_types = [HLOCAL]
166     
167     def arg_split(commandline, posix=False, strict=True):
168         """Split a command line's arguments in a shell-like manner.
169 
170         This is a special version for windows that use a ctypes call to CommandLineToArgvW
171         to do the argv splitting. The posix paramter is ignored.
172         
173         If strict=False, process_common.arg_split(...strict=False) is used instead.
174         """
175         #CommandLineToArgvW returns path to executable if called with empty string.
176         if commandline.strip() == "":
177             return []
178         if not strict:
179             # not really a cl-arg, fallback on _process_common
180             return py_arg_split(commandline, posix=posix, strict=strict)
181         argvn = c_int()
182         result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn))
183         result_array_type = LPCWSTR * argvn.value
184         result = [arg for arg in result_array_type.from_address(ctypes.addressof(result_pointer.contents))]
185         retval = LocalFree(result_pointer)
186         return result
187 except AttributeError:
188     arg_split = py_arg_split
189
```
--- 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/IPython/utils/_process_win32.py b/IPython/utils/_process_win32.py
--- a/IPython/utils/_process_win32.py
+++ b/IPython/utils/_process_win32.py
@@ -83,7 +83,7 @@
         path = None
         for ext in extensions:
             try:
-                path = SearchPath(PATH, cmd + ext)[0]
+                path = SearchPath(PATH, cmd, ext)[0]
             except:
                 pass
         if path is None:

{"golden_diff": "diff --git a/IPython/utils/_process_win32.py b/IPython/utils/_process_win32.py\n--- a/IPython/utils/_process_win32.py\n+++ b/IPython/utils/_process_win32.py\n@@ -83,7 +83,7 @@\n         path = None\n         for ext in extensions:\n             try:\n-                path = SearchPath(PATH, cmd + ext)[0]\n+                path = SearchPath(PATH, cmd, ext)[0]\n             except:\n                 pass\n         if path is None:\n", "issue": "find_cmd test failure on Windows\nI think this is caused by #3301. The [Windows implementation of find_cmd](https://github.com/ipython/ipython/blob/master/IPython/utils/_process_win32.py#L74) expects a command name without an extension, but the test now uses 'python.exe'.\n\nI think that 'python.exe' is a valid command on Windows, so I think we should modify `find_cmd` to allow passing a command with an extension. Alternatively, we could modify the test to strip the extension.\n\n```\n======================================================================\nERROR: Make sure we find sys.exectable for python.\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File \"S:\\Users\\slave\\Jenkins\\shiningpanda\\jobs\\d5f643a2\\virtualenvs\\ff035a1d\\lib\\site-packages\\nose\\case.py\", line 197, in runTest\n    self.test(*self.arg)\n  File \"S:\\Users\\slave\\Jenkins\\shiningpanda\\jobs\\d5f643a2\\virtualenvs\\ff035a1d\\lib\\site-packages\\ipython-1.0.dev-py2.7.egg\\IPython\\utils\\tests\\test_process.py\", line 36, in test_find_cmd_python\n    nt.assert_equal(find_cmd(python), sys.executable)\n  File \"S:\\Users\\slave\\Jenkins\\shiningpanda\\jobs\\d5f643a2\\virtualenvs\\ff035a1d\\lib\\site-packages\\ipython-1.0.dev-py2.7.egg\\IPython\\utils\\process.py\", line 67, in find_cmd\n    raise FindCmdError('command could not be found: %s' % cmd)\nFindCmdError: command could not be found: python.exe\n```\n\n", "before_files": [{"content": "\"\"\"Windows-specific implementation of process utilities.\n\nThis file is only meant to be imported by process.py, not by end-users.\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2010-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\nfrom __future__ import print_function\n\n# stdlib\nimport os\nimport sys\nimport ctypes\nimport msvcrt\n\nfrom ctypes import c_int, POINTER\nfrom ctypes.wintypes import LPCWSTR, HLOCAL\nfrom subprocess import STDOUT\n\n# our own imports\nfrom ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split\nfrom . import py3compat\nfrom .encoding import DEFAULT_ENCODING\n\n#-----------------------------------------------------------------------------\n# Function definitions\n#-----------------------------------------------------------------------------\n\nclass AvoidUNCPath(object):\n    \"\"\"A context manager to protect command execution from UNC paths.\n\n    In the Win32 API, commands can't be invoked with the cwd being a UNC path.\n    This context manager temporarily changes directory to the 'C:' drive on\n    entering, and restores the original working directory on exit.\n\n    The context manager returns the starting working directory *if* it made a\n    change and None otherwise, so that users can apply the necessary adjustment\n    to their system calls in the event of a change.\n\n    Example\n    -------\n    ::\n        cmd = 'dir'\n        with AvoidUNCPath() as path:\n            if path is not None:\n                cmd = '\"pushd %s &&\"%s' % (path, cmd)\n            os.system(cmd)\n    \"\"\"\n    def __enter__(self):\n        self.path = os.getcwdu()\n        self.is_unc_path = self.path.startswith(r\"\\\\\")\n        if self.is_unc_path:\n            # change to c drive (as cmd.exe cannot handle UNC addresses)\n            os.chdir(\"C:\")\n            return self.path\n        else:\n            # We return None to signal that there was no change in the working\n            # directory\n            return None\n\n    def __exit__(self, exc_type, exc_value, traceback):\n        if self.is_unc_path:\n            os.chdir(self.path)\n\n\ndef _find_cmd(cmd):\n    \"\"\"Find the full path to a .bat or .exe using the win32api module.\"\"\"\n    try:\n        from win32api import SearchPath\n    except ImportError:\n        raise ImportError('you need to have pywin32 installed for this to work')\n    else:\n        PATH = os.environ['PATH']\n        extensions = ['.exe', '.com', '.bat', '.py']\n        path = None\n        for ext in extensions:\n            try:\n                path = SearchPath(PATH, cmd + ext)[0]\n            except:\n                pass\n        if path is None:\n            raise OSError(\"command %r not found\" % cmd)\n        else:\n            return path\n\n\ndef _system_body(p):\n    \"\"\"Callback for _system.\"\"\"\n    enc = DEFAULT_ENCODING\n    for line in read_no_interrupt(p.stdout).splitlines():\n        line = line.decode(enc, 'replace')\n        print(line, file=sys.stdout)\n    for line in read_no_interrupt(p.stderr).splitlines():\n        line = line.decode(enc, 'replace')\n        print(line, file=sys.stderr)\n\n    # Wait to finish for returncode\n    return p.wait()\n\n\ndef system(cmd):\n    \"\"\"Win32 version of os.system() that works with network shares.\n\n    Note that this implementation returns None, as meant for use in IPython.\n\n    Parameters\n    ----------\n    cmd : str\n      A command to be executed in the system shell.\n\n    Returns\n    -------\n    None : we explicitly do NOT return the subprocess status code, as this\n    utility is meant to be used extensively in IPython, where any return value\n    would trigger :func:`sys.displayhook` calls.\n    \"\"\"\n    # The controller provides interactivity with both\n    # stdin and stdout\n    #import _process_win32_controller\n    #_process_win32_controller.system(cmd)\n\n    with AvoidUNCPath() as path:\n        if path is not None:\n            cmd = '\"pushd %s &&\"%s' % (path, cmd)\n        return process_handler(cmd, _system_body)\n\ndef getoutput(cmd):\n    \"\"\"Return standard output of executing cmd in a shell.\n\n    Accepts the same arguments as os.system().\n\n    Parameters\n    ----------\n    cmd : str\n      A command to be executed in the system shell.\n\n    Returns\n    -------\n    stdout : str\n    \"\"\"\n\n    with AvoidUNCPath() as path:\n        if path is not None:\n            cmd = '\"pushd %s &&\"%s' % (path, cmd)\n        out = process_handler(cmd, lambda p: p.communicate()[0], STDOUT)\n\n    if out is None:\n        out = b''\n    return py3compat.bytes_to_str(out)\n\ntry:\n    CommandLineToArgvW = ctypes.windll.shell32.CommandLineToArgvW\n    CommandLineToArgvW.arg_types = [LPCWSTR, POINTER(c_int)]\n    CommandLineToArgvW.restype = POINTER(LPCWSTR)\n    LocalFree = ctypes.windll.kernel32.LocalFree\n    LocalFree.res_type = HLOCAL\n    LocalFree.arg_types = [HLOCAL]\n    \n    def arg_split(commandline, posix=False, strict=True):\n        \"\"\"Split a command line's arguments in a shell-like manner.\n\n        This is a special version for windows that use a ctypes call to CommandLineToArgvW\n        to do the argv splitting. The posix paramter is ignored.\n        \n        If strict=False, process_common.arg_split(...strict=False) is used instead.\n        \"\"\"\n        #CommandLineToArgvW returns path to executable if called with empty string.\n        if commandline.strip() == \"\":\n            return []\n        if not strict:\n            # not really a cl-arg, fallback on _process_common\n            return py_arg_split(commandline, posix=posix, strict=strict)\n        argvn = c_int()\n        result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn))\n        result_array_type = LPCWSTR * argvn.value\n        result = [arg for arg in result_array_type.from_address(ctypes.addressof(result_pointer.contents))]\n        retval = LocalFree(result_pointer)\n        return result\nexcept AttributeError:\n    arg_split = py_arg_split\n", "path": "IPython/utils/_process_win32.py"}], "after_files": [{"content": "\"\"\"Windows-specific implementation of process utilities.\n\nThis file is only meant to be imported by process.py, not by end-users.\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2010-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\nfrom __future__ import print_function\n\n# stdlib\nimport os\nimport sys\nimport ctypes\nimport msvcrt\n\nfrom ctypes import c_int, POINTER\nfrom ctypes.wintypes import LPCWSTR, HLOCAL\nfrom subprocess import STDOUT\n\n# our own imports\nfrom ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split\nfrom . import py3compat\nfrom .encoding import DEFAULT_ENCODING\n\n#-----------------------------------------------------------------------------\n# Function definitions\n#-----------------------------------------------------------------------------\n\nclass AvoidUNCPath(object):\n    \"\"\"A context manager to protect command execution from UNC paths.\n\n    In the Win32 API, commands can't be invoked with the cwd being a UNC path.\n    This context manager temporarily changes directory to the 'C:' drive on\n    entering, and restores the original working directory on exit.\n\n    The context manager returns the starting working directory *if* it made a\n    change and None otherwise, so that users can apply the necessary adjustment\n    to their system calls in the event of a change.\n\n    Example\n    -------\n    ::\n        cmd = 'dir'\n        with AvoidUNCPath() as path:\n            if path is not None:\n                cmd = '\"pushd %s &&\"%s' % (path, cmd)\n            os.system(cmd)\n    \"\"\"\n    def __enter__(self):\n        self.path = os.getcwdu()\n        self.is_unc_path = self.path.startswith(r\"\\\\\")\n        if self.is_unc_path:\n            # change to c drive (as cmd.exe cannot handle UNC addresses)\n            os.chdir(\"C:\")\n            return self.path\n        else:\n            # We return None to signal that there was no change in the working\n            # directory\n            return None\n\n    def __exit__(self, exc_type, exc_value, traceback):\n        if self.is_unc_path:\n            os.chdir(self.path)\n\n\ndef _find_cmd(cmd):\n    \"\"\"Find the full path to a .bat or .exe using the win32api module.\"\"\"\n    try:\n        from win32api import SearchPath\n    except ImportError:\n        raise ImportError('you need to have pywin32 installed for this to work')\n    else:\n        PATH = os.environ['PATH']\n        extensions = ['.exe', '.com', '.bat', '.py']\n        path = None\n        for ext in extensions:\n            try:\n                path = SearchPath(PATH, cmd, ext)[0]\n            except:\n                pass\n        if path is None:\n            raise OSError(\"command %r not found\" % cmd)\n        else:\n            return path\n\n\ndef _system_body(p):\n    \"\"\"Callback for _system.\"\"\"\n    enc = DEFAULT_ENCODING\n    for line in read_no_interrupt(p.stdout).splitlines():\n        line = line.decode(enc, 'replace')\n        print(line, file=sys.stdout)\n    for line in read_no_interrupt(p.stderr).splitlines():\n        line = line.decode(enc, 'replace')\n        print(line, file=sys.stderr)\n\n    # Wait to finish for returncode\n    return p.wait()\n\n\ndef system(cmd):\n    \"\"\"Win32 version of os.system() that works with network shares.\n\n    Note that this implementation returns None, as meant for use in IPython.\n\n    Parameters\n    ----------\n    cmd : str\n      A command to be executed in the system shell.\n\n    Returns\n    -------\n    None : we explicitly do NOT return the subprocess status code, as this\n    utility is meant to be used extensively in IPython, where any return value\n    would trigger :func:`sys.displayhook` calls.\n    \"\"\"\n    # The controller provides interactivity with both\n    # stdin and stdout\n    #import _process_win32_controller\n    #_process_win32_controller.system(cmd)\n\n    with AvoidUNCPath() as path:\n        if path is not None:\n            cmd = '\"pushd %s &&\"%s' % (path, cmd)\n        return process_handler(cmd, _system_body)\n\ndef getoutput(cmd):\n    \"\"\"Return standard output of executing cmd in a shell.\n\n    Accepts the same arguments as os.system().\n\n    Parameters\n    ----------\n    cmd : str\n      A command to be executed in the system shell.\n\n    Returns\n    -------\n    stdout : str\n    \"\"\"\n\n    with AvoidUNCPath() as path:\n        if path is not None:\n            cmd = '\"pushd %s &&\"%s' % (path, cmd)\n        out = process_handler(cmd, lambda p: p.communicate()[0], STDOUT)\n\n    if out is None:\n        out = b''\n    return py3compat.bytes_to_str(out)\n\ntry:\n    CommandLineToArgvW = ctypes.windll.shell32.CommandLineToArgvW\n    CommandLineToArgvW.arg_types = [LPCWSTR, POINTER(c_int)]\n    CommandLineToArgvW.restype = POINTER(LPCWSTR)\n    LocalFree = ctypes.windll.kernel32.LocalFree\n    LocalFree.res_type = HLOCAL\n    LocalFree.arg_types = [HLOCAL]\n    \n    def arg_split(commandline, posix=False, strict=True):\n        \"\"\"Split a command line's arguments in a shell-like manner.\n\n        This is a special version for windows that use a ctypes call to CommandLineToArgvW\n        to do the argv splitting. The posix paramter is ignored.\n        \n        If strict=False, process_common.arg_split(...strict=False) is used instead.\n        \"\"\"\n        #CommandLineToArgvW returns path to executable if called with empty string.\n        if commandline.strip() == \"\":\n            return []\n        if not strict:\n            # not really a cl-arg, fallback on _process_common\n            return py_arg_split(commandline, posix=posix, strict=strict)\n        argvn = c_int()\n        result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn))\n        result_array_type = LPCWSTR * argvn.value\n        result = [arg for arg in result_array_type.from_address(ctypes.addressof(result_pointer.contents))]\n        retval = LocalFree(result_pointer)\n        return result\nexcept AttributeError:\n    arg_split = py_arg_split\n", "path": "IPython/utils/_process_win32.py"}]}