xml bug?

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Dec 28 19:59:52 EST 2006


At Thursday 28/12/2006 15:58, Imbaud Pierre wrote:

>The offending part is the one that goes: xmpPLUS='....'
>it triggers an exception: ValueError: too many values to unpack,
>in  _parse_ns_name. Some debugging showed an obvious mistake
>in the scanning of the name argument, that goes beyond the closing
>" ' ".
>
>Now my points are:
>- how do I spot the version of a given library? There is a __version__
>    attribute of the module, is that it?

Usually, yes. But it's not required at all, and may have another 
name. Look at the offending module.

>- I tried to copy the lib somewhere, put it BEFORE the official lib in
>    "the path" (that is:sys.path), the stack shown by the traceback
>    still shows the original files being used. Is there a special
>    mechanism bypassing the sys.path search, for standard libs? (I may
>    be wrong on this, it seems hard to believe...)

When the module is inside a package -as in this case- it's a bit 
harder. Code says `import xml.dom.modulename`, not `import 
modulename`. So even if you put modulename.py earlier in the path, it 
won't be found.
Some alternatives:
- modify the library in-place. It's the easiest way if you don't 
redistribute your code.
- same as above but using an installer (checking version numbers, of course)
- "monkey patching". That is, in a new module of your own, imported 
early on your application, write the corrected version of the offending method:

def _parse_ns_name(...):
    ...doing the right thing...

from xml.dom import modulename
modulename._parse_ns_name = _parse_ns_name

(maybe checking version numbers too)


-- 
Gabriel Genellina
Softlab SRL 


	

	
		
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 




More information about the Python-list mailing list