diff --git a/src/constructor.jl b/src/constructor.jl index c398462..72035cc 100644 --- a/src/constructor.jl +++ b/src/constructor.jl @@ -193,12 +193,20 @@ function construct_yaml_int(constructor::Constructor, node::Node) return value end - if length(value) > 2 && value[1] == '0' && (value[2] == 'x' || value[2] == 'X') - return parse(Int, value[3:end], 16) - elseif length(value) > 1 && value[1] == '0' - return parse(Int, value, 8) - else - return parse(Int, value, 10) + try + if length(value) > 2 && value[1] == '0' && (value[2] == 'x' || value[2] == 'X') + return parse(Int, value[3:end], 16) + elseif length(value) > 1 && value[1] == '0' + return parse(Int, value, 8) + else + return parse(Int, value, 10) + end + catch y + if isa(y, ArgumentError) + return value + else + error("Could not decode int, failed with error $(y)") + end end end diff --git a/test/issue41.data b/test/issue41.data new file mode 100644 index 0000000..d69dcc2 --- /dev/null +++ b/test/issue41.data @@ -0,0 +1,3 @@ +ISSBN: 0189123 +dec: 189123 +oct: 01123 diff --git a/test/issue41.expected b/test/issue41.expected new file mode 100644 index 0000000..d43567c --- /dev/null +++ b/test/issue41.expected @@ -0,0 +1 @@ +Dict{Any,Any}("ISSBN" => "0189123", "dec" => 189123, "oct" => 595) diff --git a/test/runtests.jl b/test/runtests.jl index b9c4b6d..8084f4b 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -37,6 +37,7 @@ const tests = [ "issue30", "issue36", "issue39", + "issue41" "cartesian", "ar1", "ar1_cartesian"