473,669 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

minidom + wxPython woes

Hi all,

I'm getting a seg fault when I try to use minidom to parse some XML
inside a wxPython app.

I was wondering if someone else could run the simple code below on
Linux and, if it doesn't crash horribly, post which versions of
(Python, wxPython) they are using? I can't find other messages related
to this, so I suspect it is something broken with my installation.
I'm using Python 2.4.2 and wx 2.6.1.0.

Incidentally, writing XML with minidom works fine, and this is all
happening in wxPython's main thread.
import wx
from xml.dom import minidom

app = wx.PySimpleApp( )
frame = wx.Frame(None, -1, "Hello World")
frame.Show(True )
button = wx.Button(frame , -1, "Click me")

testxml = 'xml version="1.0" ?><foo></foo>'

def click(event):
doc = minidom.parseSt ring(testxml) # seg fault?!
print "Success!"

frame.Bind(wx.E VT_BUTTON, click, button)

app.MainLoop()

Apr 7 '06 #1
9 1606
Oops, I missed a bracket... that should read:

testxml = '<xml version="1.0" ?><foo></foo>'

But it still crashes ;-)

Apr 7 '06 #2
Lonnie Princehouse wrote:
Oops, I missed a bracket... that should read:

testxml = '<xml version="1.0" ?><foo></foo>'

But it still crashes ;-)


Maybe missing a question mark still too?

<?xml version="1.0"?>

(It's like a processing instruction, not an element.)

-Peter

Apr 8 '06 #3

Lonnie Princehouse wrote:
Hi all,

I'm getting a seg fault when I try to use minidom to parse some XML
inside a wxPython app.

I was wondering if someone else could run the simple code below on
Linux and, if it doesn't crash horribly, post which versions of
(Python, wxPython) they are using? I can't find other messages related
to this, so I suspect it is something broken with my installation.
I'm using Python 2.4.2 and wx 2.6.1.0.

Incidentally, writing XML with minidom works fine, and this is all
happening in wxPython's main thread.
import wx
from xml.dom import minidom

app = wx.PySimpleApp( )
frame = wx.Frame(None, -1, "Hello World")
frame.Show(True )
button = wx.Button(frame , -1, "Click me")

testxml = 'xml version="1.0" ?><foo></foo>'

def click(event):
doc = minidom.parseSt ring(testxml) # seg fault?!
print "Success!"

frame.Bind(wx.E VT_BUTTON, click, button)

app.MainLoop()


This sounds similar to a problem I reported a few months ago. This is
the link.

http://groups.google.com/group/comp....bdf493f3c38942

In my case, it turned out to be a bug in the pyexpat module - it is
known about, but for some reason difficult to fix, so it is still
there.

I found a workaround, which is documented in the above thread.

HTH

Frank Millman

Apr 8 '06 #4
Frank Millman wrote:
This sounds similar to a problem I reported a few months ago. This is
the link.
http://groups.google.com/group/comp....bdf493f3c38942
In my case, it turned out to be a bug in the pyexpat module - it is
known about, but for some reason difficult to fix, so it is still
there.


no, it's not a bug in the pyexpat module -- the problem is that
wxPython uses it's own incompatible version of the expat library,
and loads it in a way that causes problems for any library that's
tries to use its own statically linked version.

see MvL's comments in the sourceforge tracker for more info.

</F>

Apr 8 '06 #5

Fredrik Lundh wrote:
Frank Millman wrote:
This sounds similar to a problem I reported a few months ago. This is
the link.

http://groups.google.com/group/comp....bdf493f3c38942

In my case, it turned out to be a bug in the pyexpat module - it is
known about, but for some reason difficult to fix, so it is still
there.


no, it's not a bug in the pyexpat module -- the problem is that
wxPython uses it's own incompatible version of the expat library,
and loads it in a way that causes problems for any library that's
tries to use its own statically linked version.

see MvL's comments in the sourceforge tracker for more info.

</F>


I had a look at the sourceforge tracker. I did not understand much of
it - rather too technical for me. There are two points worth noting.

Firstly, it seems from various posts to the tracker item that the same
problem has been reported with pygtk, Qt, and VTK.

Secondly, in tracker item 1295808 (which, according to the notes, is
actually the same bug), there is talk of submitting a patch in 2.5 to
address the issue.

It seems to me (FWIW - as I said, I do not really understand much of
what I read) that it may not technically be a bug in pyexpat, but there
is a real issue there, and the decision has been taken to make a change
to pyexpat so that the problem will not arise in the future.

Frank

Apr 8 '06 #6
Frank Millman wrote:
Fredrik Lundh wrote:

no, it's not a bug in the pyexpat module -- the problem is that
wxPython uses it's own incompatible version of the expat library,
and loads it in a way that causes problems for any library that's
tries to use its own statically linked version.

[...]
Firstly, it seems from various posts to the tracker item that the same
problem has been reported with pygtk, Qt, and VTK.


There used to be issues with Expat, PyXML and mod_python which may be
vaguely related to this, mostly because there was some usage of Expat
within some Apache component which conflicted with PyXML's Expat
configuration. In the end, I just dropped PyXML and started using other
libraries not affected by such issues, and I'm not totally sure that
anyone really resolved the problem definitively (although this was
possibly four or five years ago, so a lot can have happened since).

Paul

Apr 8 '06 #7
I'm hesitant to resort to tricks like "import pyexpat before wx, so
that symbols are loaded from the right library".

Luckily, I stumbled onto pxdom. It's a pure-python DOM implementation,
and switching to it was as easy as this:

# import xml.dom.minidom as dom
import pxdom as dom

Apr 10 '06 #8
Paul Boddie wrote:
Frank Millman wrote:
Fredrik Lundh wrote:

no, it's not a bug in the pyexpat module -- the problem is that
wxPython uses it's own incompatible version of the expat library,
and loads it in a way that causes problems for any library that's
tries to use its own statically linked version.


[...]
Firstly, it seems from various posts to the tracker item that the same
problem has been reported with pygtk, Qt, and VTK.


There used to be issues with Expat, PyXML and mod_python which may be
vaguely related to this, mostly because there was some usage of Expat
within some Apache component which conflicted with PyXML's Expat
configuration.


FYI, the incompatibility issues that arise with pyexpat in mod_python
are well documented at:

http://www.dscpl.com.au/articles/modpython-006.html

Graham

Apr 11 '06 #9
grah...@dscpl.c om.au wrote:

FYI, the incompatibility issues that arise with pyexpat in mod_python
are well documented at:

http://www.dscpl.com.au/articles/modpython-006.html


Nice document! Is there some possibly-similar explanation of character
encoding issues with mod_python and Expat somewhere, too, or is that
problem long forgotten?

Paul

Apr 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
7507
by: xtian | last post by:
Hi - I'm doing some data conversion with minidom (turning a csv file into a specific xml format), and I've hit a couple of small problems. 1: The output format has a header with some xml that looks something like this: <item xmlns="" xmlns:thing="http://www.blah.com"> <thing:child name="smith"/> </item>
2
2748
by: Daniel Bickett | last post by:
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming methods of the two libraries: app.MainLoop, and reactor.run. Additionally, the fact that wxPython was to receive requests from the twisted framework as well as the end user seemed to be simply asking for trouble. My initial solution was, naturally,...
5
6382
by: Mike McGavin | last post by:
Hi everyone. I've been trying for several hours now to get minidom to parse namespaces properly from my stream of XML, so that I can use DOM methods such as getElementsByTagNameNS(). For some reason, though, it just doesn't seem to want to split the prefixes from the rest of the tags when parsing. The minidom documentation at http://docs.python.org/lib/module-xml.dom.minidom.html implies that
4
6060
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3 script that grabs some web pages from the web, regex parse the data and stores it localy to xml file for further use.. at first i had no problem using python minidom and everything concerning
0
1136
by: linuxfreak | last post by:
Hi all, I downloaded the wxpython2.6 tar ball and tried building an rpm from it in an opensuse 10 computer. The command i used was rpmbuild -tb <wxpython tar file> The build worked fine and i found an 3 rpms in /usr/src/packages/RPMS/i586
18
758
by: sim.sim | last post by:
Hi all. i'm faced to trouble using minidom: #i have a string (xml) within CDATA section, and the section includes "\r\n": iInStr = '<?xml version="1.0"?>\n<Data><!]></Data>\n' #After i create DOM-object, i get the value of "Data" without "\r\n"
0
1512
by: Gary | last post by:
Howdy I ran into a difference between Python on Windows XP and Linux Fedora 6. Writing a dom to xml with minidom works on Linux. It gives an error on XP if there is an empty namespace. The problem was handled in CVS a while ago. http://mail.python.org/pipermail/xml-sig/2003-October/009904.html
3
1997
by: aine_canby | last post by:
Hi, I'm working with a number of scripts which were written years ago for my company for Python 2.2, and I'd like to update for Python 2.5. I have written a script to add # -*- coding: cp1252 -*- to the beginning of all my scripts, and that has fixed the encoding issues. Another issue was the use of - from _xmlplus.dom import minidom
2
12578
by: ashmir.d | last post by:
Hi, I am trying to parse an xml file using the minidom parser. <code> from xml.dom import minidom xmlfilename = "sample.xml" xmldoc = minidom.parse(xmlfilename) </code> The parser is failing on this line:
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.