XTM 2.0 import crashes with missing keyword argument
Closed this issue · 5 comments
GoogleCodeExporter commented
Importing my photo topic map (XTM 2.0) produces the following crash:
Traceback (most recent call last):
File "tmfs.py", line 16, in <module>
tm = import_xtm(sys.argv[1])
File "tmfs.py", line 14, in import_xtm
reader.parse(Source(file=open(filename)))
File "/Users/larsga/cvs-co/mappa/tm/trunk/src/tm/mio/deserializer.py",
line 107, in parse
self._do_parse(source)
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/
__init__.py", line 76, in _do_parse
parser.parse(as_inputsource(source))
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/xml/sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/xml/sax/expatreader.py", line 338, in start_element_ns
AttributesNSImpl(newattrs, qnames))
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/
__init__.py", line 93, in startElementNS
self._content_handler.startElementNS(name, qname, attrs)
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/
xtm10.py", line 156, in startElementNS
self._process_sid(href(attrs))
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/
xtm10.py", line 362, in _process_sid
self.map_handler.subjectIdentifier(ref)
File "/Users/larsga/cvs-co/mappa/tm/trunk/src/tm/mio/handler.py", line
299, in subjectIdentifier
self._handler.subjectIdentifier(iri)
File "/Users/larsga/cvs-co/mappa/mappa/trunk/src/mappa/miohandler.py",
line 142, in subjectIdentifier
existing = self._tm.topic(sid=sid)
File "/Users/larsga/cvs-co/mappa/mappa/trunk/src/mappa/_internal/
implhelper.py", line 89, in topic_by_identity
raise ValueError('Expected either one "sid", "slo", or "iid" keyword
argument, got: %r' % kw)
ValueError: Expected either one "sid", "slo", or "iid" keyword argument,
got: {'sid': u'http://psi.ontopedia.net/Marc_Wilhelm_K%FCster'}
Original issue reported on code.google.com by lar...@gmail.com
on 21 May 2009 at 9:45
GoogleCodeExporter commented
That's strange. I changed the MioMapHandler a bit (not using keywords anymore)
in
r123, but it seems that the detection of the XTM version does not work.
If your source is a XTM 2.0 file, the ContentHandler in xtm20.py should be
used, but
the trace shows "xtm10.py".
Does your source declare the correct XTM 2.0 namespace? Otherwise the XTM 1.0
ContentHandler is always used as fallback. Anyway, I'll let the generic XTM
ContentHandler look for the 'version' attribute if the NS is missing.
Original comment by lars.he...@gmail.com
on 21 May 2009 at 11:34
GoogleCodeExporter commented
Sorry, I was wrong. It's an XTM 1.0 file. It should have been 2.0, but it's not.
In any case, r123 (and r124) both give a different error:
Traceback (most recent call last):
File "tmfs.py", line 16, in <module>
tm = import_xtm(sys.argv[1])
File "tmfs.py", line 14, in import_xtm
reader.parse(Source(file=open(filename)))
File "/Users/larsga/cvs-co/mappa/tm/trunk/src/tm/mio/deserializer.py", line 107,
in parse
self._do_parse(source)
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/__init__.py",
line 76, in _do_parse
parser.parse(as_inputsource(source))
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/
sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/
sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/
sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/
sax/expatreader.py", line 338, in start_element_ns
AttributesNSImpl(newattrs, qnames))
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/__init__.py",
line 93, in startElementNS
self._content_handler.startElementNS(name, qname, attrs)
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/xtm10.py", line
156, in startElementNS
self._process_sid(href(attrs))
File "/Users/larsga/cvs-co/mappa/mio-xtm/trunk/src/mio/reader/xtm/xtm10.py", line
362, in _process_sid
self.map_handler.subjectIdentifier(ref)
File "/Users/larsga/cvs-co/mappa/tm/trunk/src/tm/mio/handler.py", line 299, in
subjectIdentifier
self._handler.subjectIdentifier(iri)
File "/Users/larsga/cvs-co/mappa/mappa/trunk/src/mappa/miohandler.py", line 142,
in subjectIdentifier
existing = self._tm.topic_by_sid(sid)
File "/Users/larsga/cvs-co/mappa/mappa/trunk/src/mappa/backend/mem/model.py", line
164, in topic_by_sid
return self._idman.topic_by_sid(sid)
File "/Users/larsga/cvs-co/mappa/mappa/trunk/src/mappa/backend/identityman.py",
line 184, in topic_by_sid
return self._sid2topic.get(irilib.normalize(sid))
File "/Users/larsga/cvs-co/mappa/tm/trunk/src/tm/_urlutils.py", line 119, in
normalize
return urlparse.urlunsplit((scheme,auth,path,query,fragment))
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
urlparse.py", line 235, in urlunsplit
url = '//' + (netloc or '') + url
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15:
ordinal not
in range(128)
Adding some debug code before the call to urlparse.urlunsplit produces pages
and
pages of output. Last line before the crash is:
URL: (u'http', u'psi.ontopedia.net', '/Marc_Wilhelm_K\xc3\xbcster', '', '')
So it seems Marc Wilhelm is absolutely determined to crash mappa.
Original comment by lar...@gmail.com
on 21 May 2009 at 11:47
GoogleCodeExporter commented
In the original XTM the offending character was encoded as %FC. Changing that
to the
correct %c3%bc had no effect. The error message is exactly the same. The debug
log
is different, though:
URL: (u'http', u'psi.ontopedia.net', '/Marc_Wilhelm_K\xc3\x83\xc2\xbcster', '',
'')
Original comment by lar...@gmail.com
on 21 May 2009 at 12:29
GoogleCodeExporter commented
This issue was closed by r129.
Original comment by lars.he...@gmail.com
on 21 May 2009 at 1:45
- Changed state: Fixed
GoogleCodeExporter commented
Yep, it works.
Original comment by lar...@gmail.com
on 21 May 2009 at 2:57
- Changed state: Verified