-
Notifications
You must be signed in to change notification settings - Fork 36
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
Do not use value and namespaces to sort directives #44
Conversation
The value and namespaces are dictionaries that can not be ordered.
Is there a way to trigger the problem? As far as I know all tests are passing. |
For some reason when using |
On a second though I do not really understand why d48d93c added such sorting. For me the parsing order should be always respected. |
Well, that commit is ancient history and I guess by now not even cmlenz would be able to recall the rationale. That's why I'm asking for any kind of test case which provides much more context. Personally I never touched this part of the code so I'm really out of my depth here but I hope a test case makes it easier to understand why your change is right. |
I added a test case. |
Thank you very much for the test case which clearly shows that there is a problem. I think we should merge this (with all 3 commits squashed?). @hodgestar any objections? (btw: if you merge this would you mind to use rebase merging? I prefer not to use merge commits unless there is a lot of parallel development ;-) |
For me it is just fixing the surface. I think there is a problem with Translator which in some way change the order of directives by grouping them inside the same directives list. |
The directives are sorted to ensure that they are applied in a predictable order. In Python 2, most built-in objects were comparable, so sorting by the directive index and then everything else was probably a sensible idea. In Python 3, many objects that were comparable are no longer, so sorting by arbitrary dicts, lists, etc is now a bug that wasn't picked up when we ported Genshi to Python 3. |
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.
@cedk The fix looks correct to me. Thank you for finding, reporting and fixing this old bug leftover from the port to Python 3.
This is probably a discussion for the mailing list rather than this PR. Our personal preferences seem to differ, but I have no real objection to doing other kinds of merges if it's generally appealing or particularly important to people. My preference order is probably: merge commit (single commit on the target branch & keeps commit hashes), squash commit (single commit & makes target branch tidy), rebase commits (many commits, avoids merges). |
But I still think the real problem is the need to sort the directives. Normally they should just have the same order as when they are parsed. |
@cedk The element attributes in XML are explicitly unordered -- from https://www.w3.org/TR/2006/REC-xml11-20060816/#IDA10FS:
Many directives in templates are associated with tags, which do have a parsing order, but others are not (e.g. |
The test case show the problem appears not with multiple attribute on the same tag but by having different tag directives merged into the same directive list. |
The value and namespaces are dictionaries that can not be ordered.
The sorted was added in d48d93c