Closed GoogleCodeExporter closed 9 years ago
Data in the form
proposals:
relet:
hello world:
code: print "hello world"
support:
relet: no
works as well.
Original comment by thomas.h...@gmail.com
on 8 Jul 2010 at 1:37
The issue disappears when removing the 'private' attribute of the class (I
removed it on all inner classes, just to be sure).
Original comment by thomas.h...@gmail.com
on 8 Jul 2010 at 2:06
All the YAML documents you provided are loaded by SnakeYAML 1.6 without errors.
Can you please provide some code to see what is failing ?
I did not quite catch your message about "private attribute of the class". When
the class is private then Java does not allow SnakeYAML to create an instance.
But the error message is unrelated to this problem.
-
Andrey
Original comment by py4fun@gmail.com
on 8 Jul 2010 at 3:00
Ok, I am trying to make more sense then. :)
I am running the following code as a jython webapp for tomcat:
from javax.servlet.http import HttpServlet
from org.yaml.snakeyaml import Yaml
from java.io import FileWriter, FileInputStream
...
class myServlet (HttpServlet):
def doPost(self, request, response):
...
self.yaml = Yaml()
self.data = self.yaml.load(FileInputStream("/var/lib/tomcat6/webapps/myapp/data/data.yaml"))
# do something with data
self.yaml.dump(self.data, FileWriter("/var/lib/tomcat6/webapps/myapp/data/data.yaml"))
If I create the above nested dictionary/LinkedHashMap data structure in my
code, it is dumped in the first format. Loading this format fails with said
exception when I next call the servlet.
If I modify the format manually in the meantime, as per the other two examples,
the structure is read correctly, but dumped, again, in the first format.
It may have to do with jython trying to instantiate the inner classes in the
process of interpreting/compiling the jython code that calls Yaml.load(). I am
not too familiar with its inner mode of operation yet.
Original comment by thomas.h...@gmail.com
on 8 Jul 2010 at 3:36
[deleted comment]
This is the jython program I used for testing:
print "Hello !"
import sys
sys.path.append('/home/snake/jython2.5.1/extlibs/snakeyaml-1.6.jar')
from org.yaml.snakeyaml import Yaml
from java.io import FileWriter, FileInputStream
yaml = Yaml()
data = yaml.load(FileInputStream("/home/snake/jython2.5.1/data.yaml"))
print data
yaml.dump(data, FileWriter("/home/snake/jython2.5.1/data.yaml"))
No problem so far.
Can you please try to identify the minimal code which fails to see the problem ?
Why private classes are involved if you use pure LinkedHashMap ?
-
Andrey
Original comment by py4fun@gmail.com
on 9 Jul 2010 at 9:47
Hi Andrey,
I can't seem to reproduce the bug after switching back to the unpatched
version. So I guess I'm happy.
Sorry to have bothered you. :)
Thomas
Original comment by thomas.h...@gmail.com
on 13 Jul 2010 at 10:01
(I assume you patched jython and not SnakeYAML :)
You may also try to use PyYAML. But my experience shows that using PyYAML under
jython is many times (more then 10) slower then SnakeYAML. This is because you
have to apply pure python code without C libraries.
Original comment by py4fun@gmail.com
on 13 Jul 2010 at 12:24
Original issue reported on code.google.com by
thomas.h...@gmail.com
on 8 Jul 2010 at 1:24