diff -r 418780d59502 Lib/urllib/request.py --- a/Lib/urllib/request.py Fri May 09 10:37:55 2014 -0400 +++ b/Lib/urllib/request.py Fri May 09 11:05:49 2014 -0400 @@ -1911,7 +1911,7 @@ # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily - for k in self.ftpcache.keys(): + for k in list(self.ftpcache): if k != key: v = self.ftpcache[k] del self.ftpcache[k]