From 6cd9ba610a182610cd2dd8da298ffc1b0a887c2b Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Wed, 1 Jul 2015 11:21:33 -0400 Subject: [PATCH 1/5] Deprecate utf16_is_* and utf16_get_supplementary functions 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) --- base/deprecated.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/deprecated.jl b/base/deprecated.jl index 8d5b220ef0f82..f71674dd76629 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -527,6 +527,10 @@ function start_timer(t, d, r) error("start_timer is deprecated. Use Timer(callback, delay, repeat) instead.") end +# 11551 +@deprecate utf16_is_surrogate(chr::UInt16) Base.is_surrogate_codeunit(chr) +@deprecate utf16_get_supplementary(lead::UInt16, trail::UInt16) Base.get_supplementary(lead, trail) + const UnionType = Union export UnionType From abfe2e30c48dbe9160f6f3dd4e4f1f79a09bb3eb Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Thu, 2 Jul 2015 19:48:32 -0400 Subject: [PATCH 2/5] depwarn instead of deprecate --- base/deprecated.jl | 42 ++++++++++++++++++++++++++++++++++++++---- test/choosetests.jl | 2 +- test/deprecated.jl | 19 +++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 test/deprecated.jl diff --git a/base/deprecated.jl b/base/deprecated.jl index f71674dd76629..9f99361e31470 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -527,10 +527,6 @@ function start_timer(t, d, r) error("start_timer is deprecated. Use Timer(callback, delay, repeat) instead.") end -# 11551 -@deprecate utf16_is_surrogate(chr::UInt16) Base.is_surrogate_codeunit(chr) -@deprecate utf16_get_supplementary(lead::UInt16, trail::UInt16) Base.get_supplementary(lead, trail) - const UnionType = Union export UnionType @@ -543,6 +539,44 @@ end export MathConst, @math_const +# 11551 +function utf16_is_surrogate(chr::UInt16) + depwarn(""" + Base.utf16_is_surrogate was undocumented and unexported, + and has been removed. Use Base.is_surrogate_codeunit(chr::Unsigned) instead, + however it is also undocumented and unexported, and may change in the future. + """, + symbol("utf16_is_surrogate")) + Base.is_surrogate_codeunit(chr) +end +function utf16_is_lead(chr::UInt16) + depwarn(""" + Base.utf16_is_lead was undocumented and unexported, + and has been removed. Use Base.is_surrogate_lead(chr::Unsigned) instead, + however is is also undocumented and unexported, and may change in the future. + """, + symbol("utf16_is_lead")) + Base.is_surrogate_lead(chr) +end +function utf16_is_trail(chr::UInt16) + depwarn(""" + Base.utf16_is_trail was undocumented and unexported, + and has been removed. Use Base.is_surrogate_trail(chr::Unsigned) instead, + however it is also undocumented and unexported, and may change in the future. + """, + symbol("utf16_is_trail")) + Base.is_surrogate_trail(chr) +end +function utf16_get_supplementary(lead::UInt16, trail::UInt16) + depwarn(""" + Base.utf16_get_supplementary was undocumented and unexported, + and has been removed. Use Base.get_supplementary(lead::Unsigned, trail::Unsigned) instead, + however it is also undocumented and unexported, and may change in the future. + """, + symbol("utf16_get_supplementary")) + Base.get_supplementary(lead, trail) +end + # 11280, mmap export msync diff --git a/test/choosetests.jl b/test/choosetests.jl index 2a2eecfcbe248..1766fd75ac415 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -21,7 +21,7 @@ function choosetests(choices = []) "arrayops", "tuple", "subarray", "reduce", "reducedim", "random", "abstractarray", "intfuncs", "simdloop", "blas", "sparse", "bitarray", "copy", "math", "fastmath", "functional", - "operators", "path", "ccall", "parse", "loading", + "operators", "path", "ccall", "parse", "loading", "deprecated", "bigint", "sorting", "statistics", "spawn", "backtrace", "priorityqueue", "file", "mmap", "version", "resolve", "pollfd", "mpfr", "broadcast", "complex", "socket", diff --git a/test/deprecated.jl b/test/deprecated.jl new file mode 100644 index 0000000000000..2fc6fdf9da9ca --- /dev/null +++ b/test/deprecated.jl @@ -0,0 +1,19 @@ +# This file is a part of Julia. License is MIT: http://julialang.org/license + +if (Base.JLOptions()).depwarn > 1 + @test_throws ErrorException Base.utf16_is_surrogate(0xdc00) + @test_throws ErrorException Base.utf16_is_lead(0xd800) + @test_throws ErrorException Base.utf16_is_trail(0xdc00) + @test_throws ErrorException Base.utf16_get_supplementary(0xd800, 0xdc00) +else + olderr = STDERR + try + rd, wr = redirect_stderr() + @test Base.utf16_is_surrogate(0xdc00) == true + @test Base.utf16_is_lead(0xd800) == true + @test Base.utf16_is_trail(0xdc00) == true + @test Base.utf16_get_supplementary(0xd800, 0xdc00) == 0x10000 + finally + redirect_stderr(olderr) + end +end \ No newline at end of file From b724bc7b88974eaf44e5563ea377f976a6b8b326 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Wed, 29 Jul 2015 23:15:59 -0400 Subject: [PATCH 3/5] Deprecate is_utf8_start is_utf8_continuation --- base/deprecated.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/base/deprecated.jl b/base/deprecated.jl index 9f99361e31470..3000bc8353f49 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -577,6 +577,25 @@ function utf16_get_supplementary(lead::UInt16, trail::UInt16) Base.get_supplementary(lead, trail) end +function is_utf8_start(byte::UInt8) + depwarn(""" + Base.is_utf8_start(c::UInt8) was undocumented and unexported, + and has been removed. Use !Base.is_valid_continuation(c) instead, + however it is also undocumented and unexported, and may change in the future. + """, + symbol("is_utf8_start")) + !Base.is_valid_continuation(byte) +end +function is_utf8_continuation(byte::UInt8) + depwarn(""" + Base.is_utf8_continuation(c::UInt8) was undocumented and unexported, + and has been removed. Use Base.is_valid_continuation(c) instead, + however it is also undocumented and unexported, and may change in the future. + """, + symbol("is_utf8_continuation")) + Base.is_valid_continuation(byte) +end + # 11280, mmap export msync From 4ee002ec26411ad4e509e557156814b61a4656f9 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Thu, 30 Jul 2015 11:27:11 -0400 Subject: [PATCH 4/5] Add @unexportedwarn macro, to add unexported deprecation warning 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.) --- base/deprecated.jl | 100 +++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index 3000bc8353f49..18ee71a6c1525 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -540,62 +540,54 @@ end export MathConst, @math_const # 11551 -function utf16_is_surrogate(chr::UInt16) - depwarn(""" - Base.utf16_is_surrogate was undocumented and unexported, - and has been removed. Use Base.is_surrogate_codeunit(chr::Unsigned) instead, - however it is also undocumented and unexported, and may change in the future. - """, - symbol("utf16_is_surrogate")) - Base.is_surrogate_codeunit(chr) -end -function utf16_is_lead(chr::UInt16) - depwarn(""" - Base.utf16_is_lead was undocumented and unexported, - and has been removed. Use Base.is_surrogate_lead(chr::Unsigned) instead, - however is is also undocumented and unexported, and may change in the future. - """, - symbol("utf16_is_lead")) - Base.is_surrogate_lead(chr) -end -function utf16_is_trail(chr::UInt16) - depwarn(""" - Base.utf16_is_trail was undocumented and unexported, - and has been removed. Use Base.is_surrogate_trail(chr::Unsigned) instead, - however it is also undocumented and unexported, and may change in the future. - """, - symbol("utf16_is_trail")) - Base.is_surrogate_trail(chr) -end -function utf16_get_supplementary(lead::UInt16, trail::UInt16) - depwarn(""" - Base.utf16_get_supplementary was undocumented and unexported, - and has been removed. Use Base.get_supplementary(lead::Unsigned, trail::Unsigned) instead, - however it is also undocumented and unexported, and may change in the future. - """, - symbol("utf16_get_supplementary")) - Base.get_supplementary(lead, trail) -end - -function is_utf8_start(byte::UInt8) - depwarn(""" - Base.is_utf8_start(c::UInt8) was undocumented and unexported, - and has been removed. Use !Base.is_valid_continuation(c) instead, - however it is also undocumented and unexported, and may change in the future. - """, - symbol("is_utf8_start")) - !Base.is_valid_continuation(byte) -end -function is_utf8_continuation(byte::UInt8) - depwarn(""" - Base.is_utf8_continuation(c::UInt8) was undocumented and unexported, - and has been removed. Use Base.is_valid_continuation(c) instead, - however it is also undocumented and unexported, and may change in the future. - """, - symbol("is_utf8_continuation")) - Base.is_valid_continuation(byte) + +macro unexportedwarn(old, new) + meta = Expr(:meta, :noinline) + if isa(old,Symbol) + oldname = Expr(:quote, old) + newname = Expr(:quote, new) + Expr(:toplevel, + :(function $old(args...) + $meta + depwarn(string("Base.", $oldname, " was undocumented and unexported,\n", + "and has been removed. Use ", $newname, " instead,\n", + "however it is also undocumented and unexported, and may change in the future."), + $oldname) + $new(args...) + end)) + elseif isa(old,Expr) && old.head == :call + oldcall = sprint(io->show_unquoted(io,old)) + newcall = sprint(io->show_unquoted(io,new)) + oldsym = if isa(old.args[1],Symbol) + old.args[1] + elseif isa(old.args[1],Expr) && old.args[1].head == :curly + old.args[1].args[1] + else + error("invalid usage of @unexportedwarn") + end + oldname = Expr(:quote, oldsym) + Expr(:toplevel, + :($(esc(old)) = begin + $meta + depwarn(string("Base.", $oldcall, " was undocumented and unexported,\n", + "and has been removed. Use ", $newcall, " instead,\n", + "however it is also undocumented and unexported, and may change in the future."), + $oldname) + $(esc(new)) + end)) + else + error("invalid usage of @unexportedwarn") + end end +@unexportedwarn utf16_is_surrogate(ch::Uint16) Base.is_surrogate_codeunit(ch) +@unexportedwarn utf16_is_lead(ch::UInt16) Base.is_surrogate_lead(ch) +@unexportedwarn utf16_is_trail(ch::UInt16) Base.is_surrogate_trail(ch) +@unexportedwarn utf16_get_supplementary(lead::UInt16, trail::UInt16) Base.get_supplementary(lead, trail) + +@unexportedwarn is_utf8_start(ch::UInt8) !Base.is_valid_continuation(ch) +@unexportedwarn is_utf8_continuation(ch::UInt8) Base.is_valid_continuation(ch) + # 11280, mmap export msync From 4381c3a8c653648e7628572e387e16e743640d75 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Wed, 29 Jul 2015 23:16:30 -0400 Subject: [PATCH 5/5] Test is_utf8_start is_utf8_continuation deprecations --- test/deprecated.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/deprecated.jl b/test/deprecated.jl index 2fc6fdf9da9ca..ec6cc147079aa 100644 --- a/test/deprecated.jl +++ b/test/deprecated.jl @@ -5,15 +5,19 @@ if (Base.JLOptions()).depwarn > 1 @test_throws ErrorException Base.utf16_is_lead(0xd800) @test_throws ErrorException Base.utf16_is_trail(0xdc00) @test_throws ErrorException Base.utf16_get_supplementary(0xd800, 0xdc00) + @test_throws ErrorException Base.is_utf8_start(0x40) + @test_throws ErrorException Base.is_utf8_continuation(0x90) else olderr = STDERR try rd, wr = redirect_stderr() - @test Base.utf16_is_surrogate(0xdc00) == true - @test Base.utf16_is_lead(0xd800) == true - @test Base.utf16_is_trail(0xdc00) == true + @test Base.utf16_is_surrogate(0xdc00) + @test Base.utf16_is_lead(0xd800) + @test Base.utf16_is_trail(0xdc00) @test Base.utf16_get_supplementary(0xd800, 0xdc00) == 0x10000 + @test Base.is_utf8_start(0x40) + @test Base.is_utf8_continuation(0x90) finally redirect_stderr(olderr) end -end \ No newline at end of file +end