diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 6f3b2141796c0bdc5a7b8bf8bc8fff8570dfd1bd_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..103416f893dbefd96cd6306bfa49a15bcb611d5f_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1136,7 +1136,7 @@
         # capabilities^{} key when the dict should have been
         # empty. That check can probably be removed at some point in
         # the future.)
-        if not refs or refs.keys()[0] == b'capabilities^{}':
+        if not refs or next(iter(refs.keys())) == b'capabilities^{}':
             if not exportable:
                 tip = self.repo.lookup(b'tip')
                 if tip != nullid: