-
-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix dictionary keys changed during iteration error seen in utils when using py3.8 #877
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,18 @@ class CaseInsensitiveDict(dict): | |
def __init__(self, *args, **kw): | ||
super(CaseInsensitiveDict, self).__init__(*args, **kw) | ||
|
||
self.itemlist = {} | ||
for key, value in super(CaseInsensitiveDict, self).items(): | ||
if key != key.lower(): | ||
self[key.lower()] = value | ||
self.pop(key, None) | ||
# self.itemlist = {} | ||
# for key, value in super(CaseInsensitiveDict, self).items(): | ||
# if key != key.lower(): | ||
# self[key.lower()] = value | ||
# self.pop(key, None) | ||
|
||
# self.itemlist[key.lower()] = value | ||
itemlist = {} | ||
for key, value in super(CaseInsensitiveDict, self).items(): | ||
itemlist[key.lower()] = value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use a list of keys to remove and remove them in subsequent for loop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you. Yes, that would be clearer actually and appears to work fine too:
|
||
self = itemlist | ||
|
||
|
||
def __setitem__(self, key, value): | ||
"""Overwrite [] implementation.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not leave commented out code. Remove it if it's no longer necessary.