diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca2c95..734c487 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 0.6.1 + +Bugfixes: + + * Fixed deserialization of floats (#17) + * Handle IndexError from queues properly + ### 0.6.0 Features: diff --git a/private/presenter.nim b/private/presenter.nim index 072ff04..fd54732 100644 --- a/private/presenter.nim +++ b/private/presenter.nim @@ -321,6 +321,14 @@ proc writeTagAndAnchor(target: Stream, tag: TagId, tagLib: TagLibrary, e.parent = getCurrentException() raise e +proc nextItem(c: var Queue, s: var YamlStream): + YamlStreamEvent {.raises: [YamlStreamError].} = + if c.len > 0: + try: result = c.dequeue + except IndexError: assert false + else: + result = s.next() + proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary, options: PresentationOptions = defaultPresentationOptions) = var @@ -330,7 +338,7 @@ proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary, let newline = if options.newlines == nlLF: "\l" elif options.newlines == nlCRLF: "\c\l" else: "\n" while cached.len > 0 or not s.finished(): - let item = if cached.len > 0: cached.dequeue else: s.next() + let item = nextItem(cached, s) case item.kind of yamlStartDoc: if options.style != psJson: diff --git a/private/serialization.nim b/private/serialization.nim index 662cea4..2ea7eb3 100644 --- a/private/serialization.nim +++ b/private/serialization.nim @@ -140,7 +140,8 @@ proc constructObject*[T: float|float32|float64]( constructScalarItem(s, item, T): let hint = guessType(item.scalarContent) case hint - of yTypeFloat: result = T(parseBiggestFloat(item.scalarContent)) + of yTypeFloat: + discard parseBiggestFloat(item.scalarContent, result) of yTypeFloatInf: if item.scalarContent[0] == '-': result = NegInf else: result = Inf @@ -877,4 +878,4 @@ proc dump*[K](value: K, target: Stream, tagStyle: TagStyle = tsRootOnly, try: present(events, target, serializationTagLibrary, options) except YamlStreamError: # serializing object does not raise any errors, so we can ignore this - assert false, "Can never happen" \ No newline at end of file + assert false, "Can never happen" diff --git a/yaml.nimble b/yaml.nimble index fae8f2b..b45bf68 100644 --- a/yaml.nimble +++ b/yaml.nimble @@ -1,6 +1,6 @@ # Package -version = "0.6.0" +version = "0.6.1" author = "Felix Krause" description = "YAML 1.2 implementation for Nim" license = "MIT"