We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
vox deactivate no longer resets my path
`which python3` returns the same thing before and after `vox deactivate` now.  `vox activate` correctly changes it, but `vox deactivate` no longer puts it back.  I am on the newest label of xonsh. 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `xontrib/voxapi.py`
Content:
```
1 """API for Vox, the Python virtual environment manager for xonsh."""
2 import os
3 import venv
4 import shutil
5 import builtins
6 import collections.abc
7 
8 from xonsh.platform import ON_POSIX, ON_WINDOWS, scandir
9 
10 VirtualEnvironment = collections.namedtuple('VirtualEnvironment', ['env', 'bin'])
11 
12 
13 class EnvironmentInUse(Exception):
14     pass
15 
16 
17 class NoEnvironmentActive(Exception):
18     pass
19 
20 
21 class Vox(collections.abc.Mapping):
22     """API access to Vox and virtual environments, in a dict-like format.
23 
24     Makes use of the VirtualEnvironment namedtuple:
25 
26     1. ``env``: The full path to the environment
27     2. ``bin``: The full path to the bin/Scripts directory of the environment
28     """
29 
30     def __init__(self):
31         if not builtins.__xonsh_env__.get('VIRTUALENV_HOME'):
32             home_path = os.path.expanduser('~')
33             self.venvdir = os.path.join(home_path, '.virtualenvs')
34             builtins.__xonsh_env__['VIRTUALENV_HOME'] = self.venvdir
35         else:
36             self.venvdir = builtins.__xonsh_env__['VIRTUALENV_HOME']
37 
38     def create(self, name, *, system_site_packages=False, symlinks=False,
39                with_pip=True):
40         """Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.
41 
42         Parameters
43         ----------
44         name : str
45             Virtual environment name
46         system_site_packages : bool
47             If True, the system (global) site-packages dir is available to
48             created environments.
49         symlinks : bool
50             If True, attempt to symlink rather than copy files into virtual
51             environment.
52         with_pip : bool
53             If True, ensure pip is installed in the virtual environment. (Default is True)
54         """
55         # NOTE: clear=True is the same as delete then create.
56         # NOTE: upgrade=True is its own method
57         env_path = os.path.join(self.venvdir, name)
58         venv.create(
59             env_path,
60             system_site_packages=system_site_packages, symlinks=symlinks,
61             with_pip=with_pip)
62 
63     def upgrade(self, name, *, symlinks=False, with_pip=True):
64         """Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.
65 
66         WARNING: If a virtual environment was created with symlinks or without PIP, you must
67         specify these options again on upgrade.
68 
69         Parameters
70         ----------
71         name : str
72             Virtual environment name
73         symlinks : bool
74             If True, attempt to symlink rather than copy files into virtual
75             environment.
76         with_pip : bool
77             If True, ensure pip is installed in the virtual environment.
78         """
79         # venv doesn't reload this, so we have to do it ourselves.
80         # Is there a bug for this in Python? There should be.
81         env_path, bin_path = self[name]
82         cfgfile = os.path.join(env_path, 'pyvenv.cfg')
83         cfgops = {}
84         with open(cfgfile) as cfgfile:
85             for l in cfgfile:
86                 l = l.strip()
87                 if '=' not in l:
88                     continue
89                 k, v = l.split('=', 1)
90                 cfgops[k.strip()] = v.strip()
91         flags = {
92             'system_site_packages': cfgops['include-system-site-packages'] == 'true',
93             'symlinks': symlinks,
94             'with_pip': with_pip,
95         }
96         # END things we shouldn't be doing.
97 
98         # Ok, do what we came here to do.
99         venv.create(env_path, upgrade=True, **flags)
100 
101     @staticmethod
102     def _binname():
103         if ON_WINDOWS:
104             return 'Scripts'
105         elif ON_POSIX:
106             return 'bin'
107         else:
108             raise OSError('This OS is not supported.')
109 
110     def __getitem__(self, name):
111         """Get information about a virtual environment.
112 
113         Parameters
114         ----------
115         name : str or Ellipsis
116             Virtual environment name or absolute path. If ... is given, return
117             the current one (throws a KeyError if there isn't one).
118         """
119         if name is ...:
120             env_path = builtins.__xonsh_env__['VIRTUAL_ENV']
121         elif os.path.isabs(name):
122             env_path = name
123         else:
124             env_path = os.path.join(self.venvdir, name)
125         bin_dir = self._binname()
126         bin_path = os.path.join(env_path, bin_dir)
127         # Actually check if this is an actual venv or just a organizational directory
128         # eg, if 'spam/eggs' is a venv, reject 'spam'
129         if not os.path.exists(bin_path):
130             raise KeyError()
131         return VirtualEnvironment(env_path, bin_path)
132 
133     def __iter__(self):
134         """List available virtual environments found in $VIRTUALENV_HOME.
135         """
136         # FIXME: Handle subdirs--this won't discover eg ``spam/eggs``
137         for x in scandir(self.venvdir):
138             if x.is_dir():
139                 yield x.name
140 
141     def __len__(self):
142         """Counts known virtual environments, using the same rules as iter().
143         """
144         l = 0
145         for _ in self:
146             l += 1
147         return l
148 
149     def active(self):
150         """Get the name of the active virtual environment.
151 
152         You can use this as a key to get further information.
153 
154         Returns None if no environment is active.
155         """
156         if 'VIRTUAL_ENV' not in builtins.__xonsh_env__:
157             return
158         env_path = builtins.__xonsh_env__['VIRTUAL_ENV']
159         if env_path.startswith(self.venvdir):
160             name = env_path[len(self.venvdir):]
161             if name[0] == '/':
162                 name = name[1:]
163             return name
164         else:
165             return env_path
166 
167     def activate(self, name):
168         """
169         Activate a virtual environment.
170 
171         Parameters
172         ----------
173         name : str
174             Virtual environment name or absolute path.
175         """
176         env = builtins.__xonsh_env__
177         env_path, bin_path = self[name]
178         if 'VIRTUAL_ENV' in env:
179             self.deactivate()
180 
181         type(self).oldvars = {'PATH': env['PATH']}
182         env['PATH'].insert(0, bin_path)
183         env['VIRTUAL_ENV'] = env_path
184         if 'PYTHONHOME' in env:
185             type(self).oldvars['PYTHONHOME'] = env.pop('PYTHONHOME')
186 
187     def deactivate(self):
188         """
189         Deactive the active virtual environment. Returns the name of it.
190         """
191         env = builtins.__xonsh_env__
192         if 'VIRTUAL_ENV' not in env:
193             raise NoEnvironmentActive('No environment currently active.')
194 
195         env_path, bin_path = self[...]
196         env_name = self.active()
197 
198         if hasattr(type(self), 'oldvars'):
199             for k, v in type(self).oldvars.items():
200                 env[k] = v
201             del type(self).oldvars
202 
203         env.pop('VIRTUAL_ENV')
204 
205         return env_name
206 
207     def __delitem__(self, name):
208         """
209         Permanently deletes a virtual environment.
210 
211         Parameters
212         ----------
213         name : str
214             Virtual environment name or absolute path.
215         """
216         env_path = self[name].env
217         try:
218             if self[...].env == env_path:
219                 raise EnvironmentInUse('The "%s" environment is currently active.' % name)
220         except KeyError:
221             # No current venv, ... fails
222             pass
223         shutil.rmtree(env_path)
224
```
--- 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/xontrib/voxapi.py b/xontrib/voxapi.py
--- a/xontrib/voxapi.py
+++ b/xontrib/voxapi.py
@@ -178,7 +178,7 @@
         if 'VIRTUAL_ENV' in env:
             self.deactivate()
 
-        type(self).oldvars = {'PATH': env['PATH']}
+        type(self).oldvars = {'PATH': list(env['PATH'])}
         env['PATH'].insert(0, bin_path)
         env['VIRTUAL_ENV'] = env_path
         if 'PYTHONHOME' in env:

{"golden_diff": "diff --git a/xontrib/voxapi.py b/xontrib/voxapi.py\n--- a/xontrib/voxapi.py\n+++ b/xontrib/voxapi.py\n@@ -178,7 +178,7 @@\n         if 'VIRTUAL_ENV' in env:\n             self.deactivate()\n \n-        type(self).oldvars = {'PATH': env['PATH']}\n+        type(self).oldvars = {'PATH': list(env['PATH'])}\n         env['PATH'].insert(0, bin_path)\n         env['VIRTUAL_ENV'] = env_path\n         if 'PYTHONHOME' in env:\n", "issue": "vox deactivate no longer resets my path\n`which python3` returns the same thing before and after `vox deactivate` now.  `vox activate` correctly changes it, but `vox deactivate` no longer puts it back.  I am on the newest label of xonsh. \n\n", "before_files": [{"content": "\"\"\"API for Vox, the Python virtual environment manager for xonsh.\"\"\"\nimport os\nimport venv\nimport shutil\nimport builtins\nimport collections.abc\n\nfrom xonsh.platform import ON_POSIX, ON_WINDOWS, scandir\n\nVirtualEnvironment = collections.namedtuple('VirtualEnvironment', ['env', 'bin'])\n\n\nclass EnvironmentInUse(Exception):\n    pass\n\n\nclass NoEnvironmentActive(Exception):\n    pass\n\n\nclass Vox(collections.abc.Mapping):\n    \"\"\"API access to Vox and virtual environments, in a dict-like format.\n\n    Makes use of the VirtualEnvironment namedtuple:\n\n    1. ``env``: The full path to the environment\n    2. ``bin``: The full path to the bin/Scripts directory of the environment\n    \"\"\"\n\n    def __init__(self):\n        if not builtins.__xonsh_env__.get('VIRTUALENV_HOME'):\n            home_path = os.path.expanduser('~')\n            self.venvdir = os.path.join(home_path, '.virtualenvs')\n            builtins.__xonsh_env__['VIRTUALENV_HOME'] = self.venvdir\n        else:\n            self.venvdir = builtins.__xonsh_env__['VIRTUALENV_HOME']\n\n    def create(self, name, *, system_site_packages=False, symlinks=False,\n               with_pip=True):\n        \"\"\"Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name\n        system_site_packages : bool\n            If True, the system (global) site-packages dir is available to\n            created environments.\n        symlinks : bool\n            If True, attempt to symlink rather than copy files into virtual\n            environment.\n        with_pip : bool\n            If True, ensure pip is installed in the virtual environment. (Default is True)\n        \"\"\"\n        # NOTE: clear=True is the same as delete then create.\n        # NOTE: upgrade=True is its own method\n        env_path = os.path.join(self.venvdir, name)\n        venv.create(\n            env_path,\n            system_site_packages=system_site_packages, symlinks=symlinks,\n            with_pip=with_pip)\n\n    def upgrade(self, name, *, symlinks=False, with_pip=True):\n        \"\"\"Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.\n\n        WARNING: If a virtual environment was created with symlinks or without PIP, you must\n        specify these options again on upgrade.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name\n        symlinks : bool\n            If True, attempt to symlink rather than copy files into virtual\n            environment.\n        with_pip : bool\n            If True, ensure pip is installed in the virtual environment.\n        \"\"\"\n        # venv doesn't reload this, so we have to do it ourselves.\n        # Is there a bug for this in Python? There should be.\n        env_path, bin_path = self[name]\n        cfgfile = os.path.join(env_path, 'pyvenv.cfg')\n        cfgops = {}\n        with open(cfgfile) as cfgfile:\n            for l in cfgfile:\n                l = l.strip()\n                if '=' not in l:\n                    continue\n                k, v = l.split('=', 1)\n                cfgops[k.strip()] = v.strip()\n        flags = {\n            'system_site_packages': cfgops['include-system-site-packages'] == 'true',\n            'symlinks': symlinks,\n            'with_pip': with_pip,\n        }\n        # END things we shouldn't be doing.\n\n        # Ok, do what we came here to do.\n        venv.create(env_path, upgrade=True, **flags)\n\n    @staticmethod\n    def _binname():\n        if ON_WINDOWS:\n            return 'Scripts'\n        elif ON_POSIX:\n            return 'bin'\n        else:\n            raise OSError('This OS is not supported.')\n\n    def __getitem__(self, name):\n        \"\"\"Get information about a virtual environment.\n\n        Parameters\n        ----------\n        name : str or Ellipsis\n            Virtual environment name or absolute path. If ... is given, return\n            the current one (throws a KeyError if there isn't one).\n        \"\"\"\n        if name is ...:\n            env_path = builtins.__xonsh_env__['VIRTUAL_ENV']\n        elif os.path.isabs(name):\n            env_path = name\n        else:\n            env_path = os.path.join(self.venvdir, name)\n        bin_dir = self._binname()\n        bin_path = os.path.join(env_path, bin_dir)\n        # Actually check if this is an actual venv or just a organizational directory\n        # eg, if 'spam/eggs' is a venv, reject 'spam'\n        if not os.path.exists(bin_path):\n            raise KeyError()\n        return VirtualEnvironment(env_path, bin_path)\n\n    def __iter__(self):\n        \"\"\"List available virtual environments found in $VIRTUALENV_HOME.\n        \"\"\"\n        # FIXME: Handle subdirs--this won't discover eg ``spam/eggs``\n        for x in scandir(self.venvdir):\n            if x.is_dir():\n                yield x.name\n\n    def __len__(self):\n        \"\"\"Counts known virtual environments, using the same rules as iter().\n        \"\"\"\n        l = 0\n        for _ in self:\n            l += 1\n        return l\n\n    def active(self):\n        \"\"\"Get the name of the active virtual environment.\n\n        You can use this as a key to get further information.\n\n        Returns None if no environment is active.\n        \"\"\"\n        if 'VIRTUAL_ENV' not in builtins.__xonsh_env__:\n            return\n        env_path = builtins.__xonsh_env__['VIRTUAL_ENV']\n        if env_path.startswith(self.venvdir):\n            name = env_path[len(self.venvdir):]\n            if name[0] == '/':\n                name = name[1:]\n            return name\n        else:\n            return env_path\n\n    def activate(self, name):\n        \"\"\"\n        Activate a virtual environment.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name or absolute path.\n        \"\"\"\n        env = builtins.__xonsh_env__\n        env_path, bin_path = self[name]\n        if 'VIRTUAL_ENV' in env:\n            self.deactivate()\n\n        type(self).oldvars = {'PATH': env['PATH']}\n        env['PATH'].insert(0, bin_path)\n        env['VIRTUAL_ENV'] = env_path\n        if 'PYTHONHOME' in env:\n            type(self).oldvars['PYTHONHOME'] = env.pop('PYTHONHOME')\n\n    def deactivate(self):\n        \"\"\"\n        Deactive the active virtual environment. Returns the name of it.\n        \"\"\"\n        env = builtins.__xonsh_env__\n        if 'VIRTUAL_ENV' not in env:\n            raise NoEnvironmentActive('No environment currently active.')\n\n        env_path, bin_path = self[...]\n        env_name = self.active()\n\n        if hasattr(type(self), 'oldvars'):\n            for k, v in type(self).oldvars.items():\n                env[k] = v\n            del type(self).oldvars\n\n        env.pop('VIRTUAL_ENV')\n\n        return env_name\n\n    def __delitem__(self, name):\n        \"\"\"\n        Permanently deletes a virtual environment.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name or absolute path.\n        \"\"\"\n        env_path = self[name].env\n        try:\n            if self[...].env == env_path:\n                raise EnvironmentInUse('The \"%s\" environment is currently active.' % name)\n        except KeyError:\n            # No current venv, ... fails\n            pass\n        shutil.rmtree(env_path)\n", "path": "xontrib/voxapi.py"}], "after_files": [{"content": "\"\"\"API for Vox, the Python virtual environment manager for xonsh.\"\"\"\nimport os\nimport venv\nimport shutil\nimport builtins\nimport collections.abc\n\nfrom xonsh.platform import ON_POSIX, ON_WINDOWS, scandir\n\nVirtualEnvironment = collections.namedtuple('VirtualEnvironment', ['env', 'bin'])\n\n\nclass EnvironmentInUse(Exception):\n    pass\n\n\nclass NoEnvironmentActive(Exception):\n    pass\n\n\nclass Vox(collections.abc.Mapping):\n    \"\"\"API access to Vox and virtual environments, in a dict-like format.\n\n    Makes use of the VirtualEnvironment namedtuple:\n\n    1. ``env``: The full path to the environment\n    2. ``bin``: The full path to the bin/Scripts directory of the environment\n    \"\"\"\n\n    def __init__(self):\n        if not builtins.__xonsh_env__.get('VIRTUALENV_HOME'):\n            home_path = os.path.expanduser('~')\n            self.venvdir = os.path.join(home_path, '.virtualenvs')\n            builtins.__xonsh_env__['VIRTUALENV_HOME'] = self.venvdir\n        else:\n            self.venvdir = builtins.__xonsh_env__['VIRTUALENV_HOME']\n\n    def create(self, name, *, system_site_packages=False, symlinks=False,\n               with_pip=True):\n        \"\"\"Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name\n        system_site_packages : bool\n            If True, the system (global) site-packages dir is available to\n            created environments.\n        symlinks : bool\n            If True, attempt to symlink rather than copy files into virtual\n            environment.\n        with_pip : bool\n            If True, ensure pip is installed in the virtual environment. (Default is True)\n        \"\"\"\n        # NOTE: clear=True is the same as delete then create.\n        # NOTE: upgrade=True is its own method\n        env_path = os.path.join(self.venvdir, name)\n        venv.create(\n            env_path,\n            system_site_packages=system_site_packages, symlinks=symlinks,\n            with_pip=with_pip)\n\n    def upgrade(self, name, *, symlinks=False, with_pip=True):\n        \"\"\"Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.\n\n        WARNING: If a virtual environment was created with symlinks or without PIP, you must\n        specify these options again on upgrade.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name\n        symlinks : bool\n            If True, attempt to symlink rather than copy files into virtual\n            environment.\n        with_pip : bool\n            If True, ensure pip is installed in the virtual environment.\n        \"\"\"\n        # venv doesn't reload this, so we have to do it ourselves.\n        # Is there a bug for this in Python? There should be.\n        env_path, bin_path = self[name]\n        cfgfile = os.path.join(env_path, 'pyvenv.cfg')\n        cfgops = {}\n        with open(cfgfile) as cfgfile:\n            for l in cfgfile:\n                l = l.strip()\n                if '=' not in l:\n                    continue\n                k, v = l.split('=', 1)\n                cfgops[k.strip()] = v.strip()\n        flags = {\n            'system_site_packages': cfgops['include-system-site-packages'] == 'true',\n            'symlinks': symlinks,\n            'with_pip': with_pip,\n        }\n        # END things we shouldn't be doing.\n\n        # Ok, do what we came here to do.\n        venv.create(env_path, upgrade=True, **flags)\n\n    @staticmethod\n    def _binname():\n        if ON_WINDOWS:\n            return 'Scripts'\n        elif ON_POSIX:\n            return 'bin'\n        else:\n            raise OSError('This OS is not supported.')\n\n    def __getitem__(self, name):\n        \"\"\"Get information about a virtual environment.\n\n        Parameters\n        ----------\n        name : str or Ellipsis\n            Virtual environment name or absolute path. If ... is given, return\n            the current one (throws a KeyError if there isn't one).\n        \"\"\"\n        if name is ...:\n            env_path = builtins.__xonsh_env__['VIRTUAL_ENV']\n        elif os.path.isabs(name):\n            env_path = name\n        else:\n            env_path = os.path.join(self.venvdir, name)\n        bin_dir = self._binname()\n        bin_path = os.path.join(env_path, bin_dir)\n        # Actually check if this is an actual venv or just a organizational directory\n        # eg, if 'spam/eggs' is a venv, reject 'spam'\n        if not os.path.exists(bin_path):\n            raise KeyError()\n        return VirtualEnvironment(env_path, bin_path)\n\n    def __iter__(self):\n        \"\"\"List available virtual environments found in $VIRTUALENV_HOME.\n        \"\"\"\n        # FIXME: Handle subdirs--this won't discover eg ``spam/eggs``\n        for x in scandir(self.venvdir):\n            if x.is_dir():\n                yield x.name\n\n    def __len__(self):\n        \"\"\"Counts known virtual environments, using the same rules as iter().\n        \"\"\"\n        l = 0\n        for _ in self:\n            l += 1\n        return l\n\n    def active(self):\n        \"\"\"Get the name of the active virtual environment.\n\n        You can use this as a key to get further information.\n\n        Returns None if no environment is active.\n        \"\"\"\n        if 'VIRTUAL_ENV' not in builtins.__xonsh_env__:\n            return\n        env_path = builtins.__xonsh_env__['VIRTUAL_ENV']\n        if env_path.startswith(self.venvdir):\n            name = env_path[len(self.venvdir):]\n            if name[0] == '/':\n                name = name[1:]\n            return name\n        else:\n            return env_path\n\n    def activate(self, name):\n        \"\"\"\n        Activate a virtual environment.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name or absolute path.\n        \"\"\"\n        env = builtins.__xonsh_env__\n        env_path, bin_path = self[name]\n        if 'VIRTUAL_ENV' in env:\n            self.deactivate()\n\n        type(self).oldvars = {'PATH': list(env['PATH'])}\n        env['PATH'].insert(0, bin_path)\n        env['VIRTUAL_ENV'] = env_path\n        if 'PYTHONHOME' in env:\n            type(self).oldvars['PYTHONHOME'] = env.pop('PYTHONHOME')\n\n    def deactivate(self):\n        \"\"\"\n        Deactive the active virtual environment. Returns the name of it.\n        \"\"\"\n        env = builtins.__xonsh_env__\n        if 'VIRTUAL_ENV' not in env:\n            raise NoEnvironmentActive('No environment currently active.')\n\n        env_path, bin_path = self[...]\n        env_name = self.active()\n\n        if hasattr(type(self), 'oldvars'):\n            for k, v in type(self).oldvars.items():\n                env[k] = v\n            del type(self).oldvars\n\n        env.pop('VIRTUAL_ENV')\n\n        return env_name\n\n    def __delitem__(self, name):\n        \"\"\"\n        Permanently deletes a virtual environment.\n\n        Parameters\n        ----------\n        name : str\n            Virtual environment name or absolute path.\n        \"\"\"\n        env_path = self[name].env\n        try:\n            if self[...].env == env_path:\n                raise EnvironmentInUse('The \"%s\" environment is currently active.' % name)\n        except KeyError:\n            # No current venv, ... fails\n            pass\n        shutil.rmtree(env_path)\n", "path": "xontrib/voxapi.py"}]}