Hi, Robin and Werner,
the python is available from the Linux distribution I have, and I did
not compile it.
could you please elabrate more about this point, i.e., what is
conflicting with what, and why it can conflict.
I am sorry, even though I read some articles about how python import
mechanism work, I still struggle to understand why such version
dismatch or lib conflict exist.
I made a short script and hope this could reproduce the problem.
@Robin, how to change the order of the import? it seems not work.
from xml.dom.ext.reader import Sax2
import wx
def read_by_xml_parser ():
f_string="<wxpython_xml>problem</wxpython_xml>"
reader = Sax2.Reader()
try:
print "test1_xml"
doc = reader.fromString(f_string)
except IOError, e:
print e
class ErrorApp(wx.App):
def OnInit(self):
print "test0_xml"
frame = wx.Frame(None, -1, 'error_test')
frame.Show(True)
read_by_xml_parser()
return True
app = ErrorApp(0)
app.MainLoop()
On Feb 1, 7:28 pm, Robin Dunn <ro...@alldunn.com> wrote:
> On 2/1/12 7:56 AM, werner wrote:
> > On 01/02/2012 16:27, pploo wrote:
> >> Previously I wrote a GUI with Python 2.4.3, wxPython 2.4.x, under
> >> linux. Now I am porting it with python 2.6.6, and wxPython 2.8 (I
> >> compiled the code from scratch). The majority of the GUI still works.
> >> But there are some problems with Sax2. The following is some major
> >> lines of code.
> >> from xml.dom.ext.reader import Sax2
> >> reader = Sax2.Reader()
> >> file = open(FILENAME)
> > is this save? "file" is a Python built-in which you overwrite and "open"
> > returns a "file" type.
> It just overwrites the "file" name in the local namespace. Not a good
> idea but it shouldn't cause a crashing problem.
> > would be better to call it e.g. "saxFile" or "myFile" ....
> >> file_string=file.read()
> >> doc = reader.fromString(file_string) // crashes here with
> >> "segmentation fault" error.
> >> However, If I do not use wxPython, just under the python, it is fine.
> > None of the above shows wx code, can you re-produce this in a small
> > sample? If you do "import wx" before the above code does it already
> > happen or is more needed?
> IIRC there was an issue like this long ago that had something to do with
> runtime conflicts or version mismatches between the expat library used
> by wxWidgets and the expat used by the xml modules. In that case import
> order made a difference, and I think the problem was resolved by minor
> changes in the builds (like having Python static link expat instead of
> dynamic linking it or something.) Did you build your Python yourself?
> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org