XML and ROOT

Hi, I’m getting a strange behaviour, if I want to use ROOT and the XML Parser at the same
time with python.

I’m using the standard versions of Python and ROOT for CMSSW_2_2_8:
ROOT 5.18.00a
Python 2.4.2

This code causes a segmantation fault:

import xml.dom.minidom
from ROOT import TH1F
xml.dom.minidom.parse("test.XML")

Full error msg is attached.

However if I first try to access the XML file and THEN import ROOT, it works without
problems.

import xml.dom.minidom
xml.dom.minidom.parse("test.XML")
from ROOT import TH1F

which gives me

After the import of ROOT I can still use the function.

With newer versions of Python (2.5.2) and ROOT (5.22) the first piece of code works
without problems, but I don’t want to change the CMSSW environment every time
I want to use PyROOT and XML.

Do you know how I could fix this?
I don’t want to read in a dummy XML file before the ROOT import.
error.txt (9.99 KB)

Hi,

what I find most puzzling is this:

#13 0xf7fa0c1d in PyModule_AddStringConstant (m=0x0, name=0x0, value=0x0) at Python/modsupport.c:567

b/c in initpyexpat, the module parameter is everywhere checked for NULL.

I also am not able to reproduce … Best thing I can think of is that two different system libraries are being dragged in?

However, since the problematic library is pyexpat, can you simply import it explicitly earlier? That is, does this work properly for you:import xml.dom.minidom, pyexpat from ROOT import TH1F xml.dom.minidom.parse("test.XML")
Cheers,
Wim

Thank you very much for your help!

Importing this library solved the problem.
Since it depended on the order of the commands I would never expect a missing library.