title: Redis WRONGTYPE Operation against a key holding the wrong kind of value using redis-py when calling hgetall() using keys retrieved from scan_iter
body: <p>I have a redis instance that stores data as hash. the hash key looks something like "o:t:23:45".
  I'm using redis-py and I am able to get list of keys.</p>
  
  <pre><code>for key in rc.scan_iter():
      print(key)
  </code></pre>
  
  <p>b'o:t:49:15'
  b'o:t:50:156'
  b'o:t:51:159'
  b'o:t:52:1593'
  b'o:t:53:1591'</p>
  
  <p>If I perform rc.hgetall(b'o:t:53:1591'), I am getting proper values.</p>
  
  <p>However, when I do the following:</p>
  
  <pre><code>for key in rc.scan_iter():
      rc.hgetall(key)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 2, in &lt;module&gt;
    File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 2717, in hgetall
      return self.execute_command('HGETALL', name)
    File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 839, in execute_command
      return self.parse_response(conn, command_name, **options)
    File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 853, in parse_response
      response = connection.read_response()
    File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 705, in read_response
      raise response
  redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
  </code></pre>
  
  <p>I tried to pass the key as str:</p>
  
  <pre><code>for key in rc.scan_iter():
      rc.hgetall(str(key))
  </code></pre>
  
  <p>But the results I am getting are empty dicts.
  What am I missing here? Is it possible to iterate thru a list of keys and call hgetall() to get the values for each individual key?</p>
  
  <p><strong>EDIT:</strong>
  As pointed out by <a href="https://stackoverflow.com/users/3160475/itamar-haber">Itamar</a>, the database did indeed have an entry whose key was of string type. Doing a type check before hgetall avoids the issue.</p>