Closed GoogleCodeExporter closed 9 years ago
JRuby bug: http://jira.codehaus.org/browse/JRUBY-6067
Original comment by head...@headius.com
on 13 Sep 2011 at 6:31
(a little bit off topic..)
1) SnakeYAML does not claim it is compatible with libyaml because it is not. It
is only fully compatible with PyYAML. Even though libyaml and PyYAML are from
the same developer and they are very similar, they still deviate.
2) I am impressed with the way you use SnakeYAML. And I must admit I do not
understand it. In the version 1.9, SnakeYAML has a number of methods to work
with low-level API. (parse, compose etc). But there is no way to emit events.
This is not because I want to hide anything but because I do not know how to
implement it. The way to pass the 'context' for the emitter is so ugly that I
did not dare to put it into the public API. Apparently, you have solved the
problem.
Can you may be share with us the way how you emit events ? May be we can put it
to our public API. (explanation, description, code - anything)
(back to the point)
3)
Events are created out of tokens when the document is parsed or out of
representation tree (node).
When the document is parsed then this event
ScalarEvent(anchor=null, tag=null, implicit=[true, false], value=5)
means:
there is no explicit tag and the value '5' is a subject for the implicit tag
recognition (via a set of regular expressions)
Normally, it would mean that '5' will become an Integer. But SnakeYAML may
create a Long (when Integer does not fit) or String (if it is a value for a
JavaBean property of type String)
While when an object is emitted then the situation is different. Without a tag
there is no way for the emitter to find out how to emit '7'. Integer and String
must be emitted differently. It makes it even more complicated when the
emitter's 'context' dictates single or double quoted values (because implicit
tags are gone).
To give you more information I have created a test:
http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyam
l/issues/issue132/ScalarEventTagTest.java
Feel free to take it and play with it.
It means the following. Two bugs are combined together in a way that it works
under curtain conditions. First bug is in Psych, it loses the runtime
information about a value (integers become strings). Second bug is in libyaml,
it makes an assumption that if a tag is not present it should be string.
When you only emit strings then these 2 bugs work together like a charm :)
We can continue as following:
a) play with JRuby to prove that integers (dates, booleans and others
http://www.yaml.org/type/) are not emitted properly
b) file a bug in Psych that the tag is required
c) [optional] file a bug in libyaml that it should not make an intelligent
guess about the tag when it is not explicitly provided for emitter (because it
is not intelligent enough :)
d) share with us the results of your investigation
Feel free to ask further questions.
Andrey
Original comment by py4fun@gmail.com
on 14 Sep 2011 at 9:13
This can be closed as wontfix for now.
The author of the "psych" library we emulate atop SnakeYAML has been updating
the general structure of psych and our specific implementation to pass more
tests. He has also decided he likes how SnakeYAML is structured and is moving
psych toward that structure.
This issue was reported by me primarily because I saw it in psych tests, but
with the original author attempting to clean those up we can ignore this for
now.
Original comment by head...@headius.com
on 28 Sep 2012 at 9:32
Original comment by py4fun@gmail.com
on 28 Sep 2012 at 10:38
Original issue reported on code.google.com by
head...@headius.com
on 13 Sep 2011 at 6:29