-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Deprecate utf16_is_*, utf16_get_supplementary, is_utf8_*, add @unexportedwarning macro, add tests #11976
Conversation
I believe policy is not to add deprecations for unexported/undocumented internal functions, though I may be out of date on that. |
@pao I'm just doing what I was told to do! |
Yeah, I see that now--I hit this issue before I saw the comments on the commit. Carry on. |
But let's add a cf 9071f14#commitcomment-11953239 |
If somebody can merge this quickly, I'd appreciate it, so it can make JSON happy again! |
Best to cross-reference everything since discussions happen in multiple places - merging #11551 broke JSON.jl. I think the |
I wasn't aware of that technique, I've only used |
@tkelman Is this what you were thinking of? function utf16_is_surrogate(chr::UInt16)
depwarn("utf16_is_surrogate was undocumented and unexported, and has been removed")
Base.is_surrogate_codeunit(chr)
end
function utf16_get_supplementary(lead::UInt16, trail::UInt16)
depwarn("utf16_get_supplementary was undocumented and unexported, and has been removed")
Base.get_supplementary(lead, trail)
end I have this ready to push to this PR, if you think it is better. |
@tkelman why would we deprecate these if they weren't exported? If packages need to touch these then I'd rather formally export an equivalent in 0.4, and make it work on 0.3 via Compat. |
@IainNZ In the registered packages, only |
Technically a deprecation isn't absolutely required if the breakage can be solved via Compat, or these look short enough that they're just pasted in as one-liners for the JSON use case. Let's see what else was using the deleted/renamed functions from #11551. If we do the manual deprecation without exporting, then I would still want to keep the warning message like a conventional depwarn with a message about what to replace Lines 493 to 494 in e063f77
|
@tkelman, as far as I can tell by grepping, it's just those 2 occurrences in |
cfbfbd2
to
c3792d7
Compare
I finally pushed the changes I'd made last week to use depwarn. |
sure, but you didn't do
|
Still not seeing the point of doing this, feel like it should should just be allowed to break in whatever hypothetical user code out that there that is using this undocumented, unexported feature. |
Considering the important case of JSON has been fixed, I'm inclined to agree for now, did any of the PackageEvaluator results show anything that looked like it was caused by this? |
I didn't see anything, but its a bit of a mess on 0.4 anyway that this is probably the least of anyones worries. Could put something NEWS.md if really paranoid? |
c3792d7
to
5a6b2f3
Compare
The problem there is, I didn't really think they should call the new functions (which are slightly different, to be able to handle UTF-16 stored in UTF-16 or in UTF-8 (i.e. CESU-8)). It took me longer that I thought for, busy with kids. I see other people have commented. |
5a6b2f3
to
2d73774
Compare
This now does depwarn as @tkelman wanted, and also adds tests (along with adding a new |
2d73774
to
149de7a
Compare
This is mergeable again, and should help increase the testing coverage. |
no, there's a conflict, needs a rebase |
149de7a
to
46618cd
Compare
Darn, I had it all up-to-date before we went away this weekend! I feel like Job sometimes, continuously dealing with merge conflicts! It should be fine now (Jeff had added some deprecations, not sure why git couldn't handle the merge) |
Tests passed now, all ready again. |
46618cd
to
34b1eae
Compare
Bump: this deprecates the usage of 6 undocumented, unexported functions in the UTF-8 and UTF-16 handling code, that have already been used in packages, that have been replaced by more generic functions. It also adds tests for all 6, and shows a way of adding coverage tests for the deprecations themselves (as I've seen occurrences of bugs getting introduced in the deprecation code itself). |
@@ -539,6 +539,63 @@ end | |||
|
|||
export MathConst, @math_const | |||
|
|||
# 11551 | |||
function utf16_is_surrogate(chr::UInt16) |
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.
This is a lot of (almost) exactly repeated code. Should really use a for loop and a macro, at least for all the single-arg cases.
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.
OK, good point! Thanks! (I'm just not yet good at macros, but this is probably easy enough for me to learn how quickly)
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.
It might not be worth the trouble. Since JSON has been fixed, the need for this PR is questionable.
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.
I found other places, added the deprecations for is_utf8_start
& is_utf8_continuation
,
and I think it sets a good precedent for people to add unit tests for deprecations.
34b1eae
to
7c8c4a9
Compare
Bump: This passes, all done with a macro which can be used for any future deprecations of unexported functions, and unit tests. |
These functions were undocumented and unexported, and were not generic. They have been replaced by other, generic functions, that will work on unsigned values of any size. Although it is not normal to have to deprecate unexported functions, these are being used in some packages (notably JSON.jl, which is used by many other packages)
This will allow people to easily deprecate functions that were supposed to be private, but got used in packages (like Base.indentation, Base.unindent, Base.is_utf_start, etc.)
7c8c4a9
to
4381c3a
Compare
Bump? I'd love to have this facility to easily deprecate functions that have been used outside of Base, which where unexported and undocumented (meant to be essentially private). |
It took me quite a while to figure out what this PR is even doing since it doesn't explain anywhere. It seems to be doing for non-exported names what the
If someone used something in Base that wasn't exported and it gets removed, then their code will break and they can fix it. |
@StefanKarpinski: See 9071f14#commitcomment-11953239 for the origins of this. |
Yeah, even though I originally whined about it, we definitely don't need to deprecate un-exported methods. As I suggested there, it's certainly a good faith effort to search existing packages and notify authors, but we definitely don't need to deprecate. |
This already bit me in a big way once, and the other deprecation I put in this PR is for another function that is used in at least one package. With this, I can remove unexported functions from base, without having to worry about causing lots of breakage. Another thing is that just because something is not exported, doesn't mean that it is not meant to be used outside of the module (which is why the accessibility or private distinction is important). A good counter-example is Finally, deprecations only need to be maintained for one release cycle. About the |
@StefanKarpinski: Do you have objections closing this. |
No, fine by me. There's a pattern here. |
Discussion moved to #12647 |
Although these were undocumented, unexported functions internal to the utf16.jl code, they got used in the JSON package.
(I will also submit a PR to fix JSON)