Skip to content

Second example NoneType bug #16

@stroebel

Description

@stroebel

When running the example from the documentation I get the following error. It looks like gymnasium is perhaps passing in a nonetype where your default value is dict.

The correct fix is likely to make your own default value None and handle it by changing it to a dict, as mutable default args is not great anyway.

Example in question:

import gymnasium as gym
import gym_simplegrid

env = gym.make('SimpleGrid-8x8-v0', render_mode='human')
env.reset()
done = env.unwrapped.done

for _ in range(50):
    if done:
        break
    action = env.action_space.sample()
    obs, reward, done, _, info = env.step(action)
env.close()

Error:

180 """
    181 parse the value of an option of type state from the dictionary of options usually passed to the reset method. Such value denotes a position on the map and it must be an int or a tuple.
    182 """
    183 try:
--> 184     state = options[state_name]
    185     if isinstance(state, int):
    186         return self.to_xy(state)

TypeError: 'NoneType' object is not subscriptable

Potential issue:

File ~/projects/conv_discv/basic_envs/.venv/lib/python3.12/site-packages/gymnasium/core.py:333, in Wrapper.reset(self, seed, options)
    329 def reset(
    330     self, *, seed: int | None = None, options: dict[str, Any] | None = None
    331 ) -> tuple[WrapperObsType, dict[str, Any]]:
    332     """Uses the :meth:`reset` of the :attr:`env` that can be overwritten to change the returned data."""
--> 333     return self.env.reset(seed=seed, options=options)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions