Browse files

Make sure env.spec always exists and is valid. (#621)

* Make sure env.spec always exists and is valid. Previously there was an error when you tried to get the string representation of an unregistered env.

* update changelist
  • Loading branch information...
joschu committed Jun 16, 2017
1 parent 92a17bd commit 2b30434d14a5bd27087ae672264a9f8beb90947e
Showing with 11 additions and 8 deletions.
  1. +2 −0 README.rst
  2. +8 −7 gym/
  3. +1 −1 gym/envs/
@@ -262,6 +262,8 @@ We are using `pytest <>`_ for tests. You can run them via:
What's new
- 2017-06-16: Make env.spec into a property to fix a bug that occurs
when you try to print out an unregistered Env.
- 2017-05-13: BACKWARDS INCOMPATIBILITY: The Atari environments are now at
*v4*. To keep using the old v3 environments, keep gym <= 0.8.2 and atari-py
<= 0.0.21. Note that the v4 environments will not give identical results to
@@ -51,6 +51,7 @@ def __new__(cls, *args, **kwargs):
env = super(Env, cls).__new__(cls)
env._env_closer_id = env_closer.register(env)
env._closed = False
env._spec = None
# Will be automatically set when creating an environment via 'make'
return env
@@ -76,10 +77,6 @@ def _seed(self, seed=None): return []
# Do not override
_owns_render = True
def monitor(self):
raise error.Error("env.monitor has been deprecated as of 12/23/2016. Remove your call to `env.monitor.start(directory)` and instead wrap your env with `env = gym.wrappers.Monitor(env, directory)` to record data.")
def step(self, action):
"""Run one timestep of the environment's dynamics. When end of
episode is reached, you are responsible for calling `reset()`
@@ -189,6 +186,10 @@ def seed(self, seed=None):
return self._seed(seed)
def spec(self):
return self._spec
def unwrapped(self):
"""Completely unwrap this env.
@@ -202,10 +203,10 @@ def __del__(self):
def __str__(self):
if self.spec is not None:
return '<{}<{}>>'.format(type(self).__name__,
if self.spec is None:
return '<{} instance>'.format(type(self).__name__)
return '<{}<{}>>'.format(type(self).__name__,
def configure(self, *args, **kwargs):
raise error.Error("Env.configure has been removed in gym v0.8.0, released on 2017/03/05. If you need Env.configure, please use gym version 0.7.x from pip, or checkout the `gym:v0.7.4` tag from git.")
@@ -86,7 +86,7 @@ def make(self):
env = cls(**self._kwargs)
# Make the enviroment aware of which spec it came from.
env.unwrapped.spec = self
env.unwrapped._spec = self
return env

0 comments on commit 2b30434

Please sign in to comment.