title: psycopg2.extras.DictRow behaves differently using for vs. next
body: <p>This is v2.8.5 running in python 3.8.5. The following works as expected:</p>
  <pre><code>  curs = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)
    curs.execute(&quot;select fid from A&quot;)
    for row in curs:                                                   
      print(row['fid'])                                                   
  </code></pre>
  <p>but this does not:</p>
  <pre><code>  row = next(curs, None)                                             
    print(row['fid'])                                                       
  
    File &quot;/usr/local/lib/python3.8/site-packages/psycopg2/extras.py&quot;, line 168, in __getitem__
      x = self._index[x]
  KeyError: 'fid'
  
  </code></pre>
  <p>The type of <code>row</code> is <code>&lt;class 'psycopg2.extras.DictRow'&gt;</code> in both cases.</p>
  <p>Obvious pilot error somewhere?</p>