-
Notifications
You must be signed in to change notification settings - Fork 674
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
use OrderDict because csv.DictReader returns a dict after version 3.7 #2496
use OrderDict because csv.DictReader returns a dict after version 3.7 #2496
Conversation
net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/lib/haproxy/cmds.py
Outdated
Show resolved
Hide resolved
LGTM, I'll apply the same fix for the statistics script. |
I don't want to spoil the fun here, but are we sure we're fixing the right thing? The end result seems to be a dict() anyway
|
@AdSchellevis imho not just a dict() is needed, but an OrderedDict for move_to_end() to work at plugins/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/lib/haproxy/cmds.py Lines 329 to 331 in c149e55
|
@kulikov-a it won't stick to the end when casting to dict() later on :) (if it does, it's pure luck) |
@AdSchellevis ah, got it, thanks. but shouldn't the order be preserved if (starting from 3.7) it is declared that the dict() preserves the insertion order (https://docs.python.org/3/whatsnew/3.7.html)? |
@AdSchellevis |
@kulikov-a I kind of missed that item in the release notes, my point just is that if the order doesn't matter in real life, best don't try to make it look like it does..... trusting ordering in named array types is often quite dangerous and prone to errors. Eventually it wraps into a json container, which likely doesn't care about order either.
It's not my code, if @fraenki choses to accept it I don't mind, spending years on reverse engineering of all sorts of weirdness in our old code just makes my eyes hurt. |
@AdSchellevis thanks for the explanation. thought that |
@kulikov-a that is good to know, but since it wasn't earlier, its likely safe to assume order doesn't matter (in which case someone could just add "id" to the container and be done with it) |
I can confirm that it fixes the maintenance page, so the targeted issues is solved. |
See: python/cpython#8014