Implement #clone correctly with respect to singleton classes#3117
Merged
flavorjones merged 8 commits intomainfrom Feb 2, 2024
Merged
Implement #clone correctly with respect to singleton classes#3117flavorjones merged 8 commits intomainfrom
#clone correctly with respect to singleton classes#3117flavorjones merged 8 commits intomainfrom
Conversation
d9d4b84 to
81a8f14
Compare
which unlocks the ability to rely on the Ruby default `#dup` and `#clone` implementations.
81a8f14 to
253d699
Compare
The next commit is going to introduce some layers of indirection to `#copy` and `#dup` that can raise exceptions, and we need this safety net in order to avoid segfaults while constructing exception messages.
Partially fixes #316
which unlocks the ability to rely on the Ruby default `#dup` and `#clone` implementations.
62e6361 to
005fe03
Compare
1387f66 to
5acd0f3
Compare
flavorjones
commented
Feb 1, 2024
| # [Returns] The new Nokogiri::XML::Document | ||
| # | ||
| def dup(level = 1) | ||
| copy = OBJECT_DUP_METHOD.bind_call(self) |
Member
Author
There was a problem hiding this comment.
I don't particularly like the bind_call hack here and in and #clone, but I can't come up with anything better.
5acd0f3 to
7955303
Compare
flavorjones
added a commit
that referenced
this pull request
Feb 2, 2024
…pgrade (#3118) **What problem is this PR intended to solve?** - some minor C code cleanup - improved testing around `Node#dup` that should have been in #3117 - update CI to use `download-artifact` and `upload-artifact` v4 **Have you included adequate test coverage?** Yes. **Does this change affect the behavior of either the C or the Java implementations?** No functional changes.
This was referenced Dec 6, 2024
Open
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again.
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again. (cherry picked from commit dda0be2)
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
**What problem is this PR intended to solve?** Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. **Have you included adequate test coverage?** The skipped test is no longer skipped! Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again. **Does this change affect the behavior of either the C or the Java implementations?** Brings the Java impl into agreement with the C impl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem is this PR intended to solve?
Fixes #316
Classes this PR updates:
XML::NodeXML::DocumentXML::NodeSetHave you included adequate test coverage?
Yes.
Does this change affect the behavior of either the C or the Java implementations?
The fix applies to both implementations.