Skip to content
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

Fix compatibility with Julia 0.7 #30

Merged
merged 3 commits into from
Jun 6, 2018
Merged

Fix compatibility with Julia 0.7 #30

merged 3 commits into from
Jun 6, 2018

Conversation

ararslan
Copy link
Contributor

@ararslan ararslan commented May 14, 2018

This change allows the package to load on 0.7 and also fixes all deprecations emitted on 0.7.

...once it's done

@ararslan ararslan requested a review from spurll May 14, 2018 21:43
@ararslan ararslan changed the title Fix compatibility with Julia 0.7 WIP: Fix compatibility with Julia 0.7 May 14, 2018
@ararslan ararslan force-pushed the aa/0.7 branch 2 times, most recently from 5d6dedb to addc82e Compare May 14, 2018 23:14
@ararslan
Copy link
Contributor Author

This is happening on 0.7, not sure what to make of it yet:

ERROR: LoadError: UndefVarError: T not defined
Stacktrace:
 [1] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Type{fatal: error thrown and no exception handler available.
UndefVarError(var=:T)
rec_backtrace at /home/alex/Projects/julia/src/stackwalk.c:94
record_backtrace at /home/alex/Projects/julia/src/task.c:246
jl_throw at /home/alex/Projects/julia/src/task.c:577
jl_undefined_var_error at /home/alex/Projects/julia/src/rtutils.c:134
show at /home/alex/.julia/v0.7/Intervals/src/anchoredinterval.jl:180
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
show_datatype at ./show.jl:520
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
show at ./show.jl:437
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
print at ./strings/io.jl:29
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
print at ./strings/io.jl:40
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
show_tuple_as_call at ./show.jl:1536
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
show_spec_linfo at ./stacktraces.jl:285
#show#9 at ./stacktraces.jl:295
unknown function (ip: 0x7fceeedee213)
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
#show at ./<missing>:0 [inlined]
#show_trace_entry#665 at ./errorshow.jl:476 [inlined]
#show_trace_entry at ./<missing>:0
unknown function (ip: 0x7fceeeded7f8)
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
show_backtrace at ./errorshow.jl:503
#showerror#647 at ./errorshow.jl:79
unknown function (ip: 0x7fceeedec017)
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
#showerror at ./<missing>:0
unknown function (ip: 0x7fceeedebc62)
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
#showerror#650 at ./errorshow.jl:85
unknown function (ip: 0x7fceeedebb67)
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
showerror at ./errorshow.jl:84
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
display_error at ./client.jl:165
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
display_error at ./client.jl:168
inner at ./essentials.jl:661
jl_fptr_trampoline at /home/alex/Projects/julia/src/gf.c:1816
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
jl_apply at /home/alex/Projects/julia/src/julia.h:1540 [inlined]
jl_f__apply at /home/alex/Projects/julia/src/builtins.c:561
jl_f__apply_latest at /home/alex/Projects/julia/src/builtins.c:599
#invokelatest#3 at ./essentials.jl:662 [inlined]
invokelatest at ./essentials.jl:661 [inlined]
_start at ./client.jl:459
jl_apply_generic at /home/alex/Projects/julia/src/gf.c:2133
jl_apply at /home/alex/Projects/julia/ui/../src/julia.h:1540 [inlined]
true_main at /home/alex/Projects/julia/ui/repl.c:109
main at /home/alex/Projects/julia/ui/repl.c:240
__libc_start_main at /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
_start at /home/alex/Projects/julia/usr/bin/julia (unknown line)

@ararslan
Copy link
Contributor Author

AHA! It's JuliaLang/julia#24195. Indeed:

$ sift -e 'Base\.show'
src/inclusivity.jl:43:function Base.show(io::IO, x::Inclusivity)
src/interval.jl:109:function Base.show(io::IO, interval::Interval{T}) where T
src/anchoredinterval.jl:173:Base.show(io::IO, ::Type{HourEnding}) = print(io, "HourEnding{T}")
src/anchoredinterval.jl:174:Base.show(io::IO, ::Type{HourBeginning}) = print(io, "HourBeginning{T}")
src/anchoredinterval.jl:176:Base.show(io::IO, ::Type{HourEnding{T}}) where T <: TimeType = print(io, "HourEnding{$T}")
src/anchoredinterval.jl:177:Base.show(io::IO, ::Type{HourBeginning{T}}) where T <: TimeType = print(io, "HourBeginning{$T}")
src/anchoredinterval.jl:179:function Base.show(io::IO, ::Type{AnchoredInterval{P, T}}) where {P, T}
src/anchoredinterval.jl:183:function Base.show(io::IO, interval::T) where T <: AnchoredInterval

We should not be overloading show with ::Type arguments. That is, according to Jeff himself, Type TreasonTM.

@codecov
Copy link

codecov bot commented May 15, 2018

Codecov Report

Merging #30 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #30   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines         184    179    -5     
=====================================
- Hits          184    179    -5
Impacted Files Coverage Δ
src/description.jl 100% <ø> (ø) ⬆️
src/anchoredinterval.jl 100% <100%> (ø) ⬆️
src/interval.jl 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29f60b3...a0d86e3. Read the comment docs.

@ararslan
Copy link
Contributor Author

This is an odd error that only happens on 0.7:

display: Error During Test at /home/travis/.julia/v0.7/Intervals/test/anchoredinterval.jl:164
  Test threw exception MethodError(Intervals.description, (2016-08-11T02:00:00-05:00, 1 hour, "E"), 0x0000000000006b37)
  Expression: string(interval) == "(2016-08-11 HE02-05:00]"
  MethodError: no method matching description(::ZonedDateTime, ::Hour, ::String)
  Closest candidates are:
    description(!Matched::Date, ::Period, ::String) at /home/travis/.julia/v0.7/Intervals/src/description.jl:21
    description(!Matched::Dates.AbstractDateTime, ::Period, ::String) at /home/travis/.julia/v0.7/Intervals/src/description.jl:26
  Stacktrace:
   [1] description(::AnchoredInterval{-1 hour,ZonedDateTime}, ::String) at /home/travis/.julia/v0.7/Intervals/src/description.jl:12
   [2] description at /home/travis/.julia/v0.7/Intervals/src/description.jl:1 [inlined]
   [3] print at /home/travis/.julia/v0.7/Intervals/src/anchoredinterval.jl:191 [inlined]
   [4] #print_to_string#335 at ./strings/io.jl:122 [inlined]
   [5] print_to_string at ./strings/io.jl:110 [inlined]
   [6] string(::AnchoredInterval{-1 hour,ZonedDateTime}) at ./strings/io.jl:141
   [7] macro expansion at /home/travis/.julia/v0.7/Intervals/test/anchoredinterval.jl:164 [inlined]
   [8] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:1079 [inlined]
   [9] macro expansion at /home/travis/.julia/v0.7/Intervals/test/anchoredinterval.jl:107 [inlined]
   [10] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:1079 [inlined]
   [11] top-level scope at /home/travis/.julia/v0.7/Intervals/test/anchoredinterval.jl:4

@rofinn
Copy link
Member

rofinn commented May 17, 2018

ZonedDateTime currently doesn't subtype AbstractDateTime on 0.7, but it does subtype TimeType which is what Compat.AbstractDateTime is an alias for on 0.6. TimeZones should probably be updated to use Compat.AbstractDateTime for now.

@ararslan
Copy link
Contributor Author

Tests pass on 0.7 with JuliaTime/TimeZones.jl#137. There are still a few deprecation warnings to tackle though.

rofinn
rofinn previously approved these changes May 19, 2018
Copy link
Member

@rofinn rofinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me. I'd review the TimeZones.jl change as well, but I'm not a member of JuliaTime.

@rofinn rofinn dismissed their stale review May 19, 2018 01:55

Intended to comment rather than approve.

REQUIRE Outdated
@@ -1,3 +1,3 @@
julia 0.6
TimeZones 0.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be bumped up to 0.7


function Base.show(io::IO, ::Type{AnchoredInterval{P, T}}) where {P, T}
print(io, "AnchoredInterval{$P, $T}")
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention was to avoid these being fully qualified on Julia 0.6. Should we just have a version check around this to limit it's usage to Julia 0.6?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that it's always a Bad Thing To DoTM, it's just penalized with actual crashing on 0.7.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it always a bad thing to do? I'm mostly just curious so I can give some rational against doing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #31, in particular the link to Jeff's comment. Basically it's redefining what it means to call show on a Type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

test/runtests.jl Outdated
compactstring(x) = sprint(show, x, context=:compact=>true)
else
compactstring(x) = sprint(showcompact, x)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this won't work generally in Compat we can use this here to use the new 0.7 sprint syntax instead of making a new function:

if VERSION < v"0.7.0-DEV.4524"
    function sprint(f::Function, args...; context=nothing)
        if context !== nothing
            Base.sprint((io, args...) -> f(IOContext(io, context), args...), args...)
        else
            Base.sprint(f, args...)
        end
    end
end

Then we can just use sprint(show, x, context=:compact=>true) in the tests.

In particular:

* Use definitions from Compat, e.g. Compat.Dates

* Define a local version of sprint(show, args; kwargs), as this is not
  available in Compat

* Use arguments in DomainError constructors

* Remove custom show methods for types

* Raise the minimum required version of TimeZones
@ararslan
Copy link
Contributor Author

ararslan commented Jun 4, 2018

Tests are passing on 0.7 now. 🙂 There are still a few more deprecations, in particular Int constructor vs convert and colon.

@@ -5,6 +5,7 @@ os:
- osx
julia:
- 0.6
- 0.7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to add 0.7 on AppVeyor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, Windows!

@ararslan
Copy link
Contributor Author

ararslan commented Jun 4, 2018

I think we should go ahead and merge this once CI finishes so that the package works on 0.7, then the remaining deprecations can be addressed separately.

@ararslan ararslan changed the title WIP: Fix compatibility with Julia 0.7 Fix compatibility with Julia 0.7 Jun 5, 2018
@omus
Copy link
Collaborator

omus commented Jun 5, 2018

@ararslan I'm ok with merging as is. Looks like AppVeyor is failing from a TimeZones.jl compatibility issue. Do you want to wait for TimeZones to be fixed or just merge this?

@omus
Copy link
Collaborator

omus commented Jun 5, 2018

Hopefully will be addressed with: JuliaTime/TimeZones.jl#139

@ararslan
Copy link
Contributor Author

ararslan commented Jun 5, 2018

Do you want to wait for TimeZones to be fixed or just merge this?

I'll leave that up to you.

@omus
Copy link
Collaborator

omus commented Jun 6, 2018

The TimeZones issue more trouble than I originally thought. I won't hold this up any longer. I'll tag a new version tomorrow.

@omus omus merged commit 3addff5 into master Jun 6, 2018
@omus omus deleted the aa/0.7 branch June 6, 2018 04:56
@omus omus mentioned this pull request Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants