summaryrefslogtreecommitdiffstats
path: root/Lib/xml/sax/__init__.py
diff options
context:
space:
mode:
authorPaul Prescod <prescod@prescod.net>2000-07-01 04:58:47 (GMT)
committerPaul Prescod <prescod@prescod.net>2000-07-01 04:58:47 (GMT)
commit73678dac48e5858e40cba6d526970cba7e7c769c (patch)
tree9cb93c23e4a2cd4a881e86694f8204e33c2ed106 /Lib/xml/sax/__init__.py
parent8fcaa92c5f4290c0ea31f2680c87635bc751303f (diff)
downloadcpython-73678dac48e5858e40cba6d526970cba7e7c769c.zip
cpython-73678dac48e5858e40cba6d526970cba7e7c769c.tar.gz
cpython-73678dac48e5858e40cba6d526970cba7e7c769c.tar.bz2
Reference cycle fixes
Diffstat (limited to 'Lib/xml/sax/__init__.py')
-rw-r--r--Lib/xml/sax/__init__.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py
index 5d0fea5..324558d 100644
--- a/Lib/xml/sax/__init__.py
+++ b/Lib/xml/sax/__init__.py
@@ -23,3 +23,27 @@ from _exceptions import *
from saxutils import *
from _exceptions import SAXParseException
import xmlreader
+
+def parse( filename_or_stream, handler, errorHandler=ErrorHandler() ):
+ parser=ExpatParser()
+ parser.setContentHandler( handler )
+ parse.setErrorHandler( errorHandler )
+ parser.parse( filename_or_stream )
+
+# this may not work yet...Expat doesn't handle buffer inputs
+def parseString( string, handler, errorHandler=ErrorHandler() ):
+ try:
+ import cStringIO
+ stringio=cStringIO.StringIO
+ except ImportError:
+ import StringIO
+ stringio=StringIO.StringIO
+
+ bufsize=len( string )
+ buf=stringio( string )
+
+ parser=ExpatParser()
+ parser.setContentHandler( handler )
+ parse.setErrorHandler( errorHandler )
+ parser.parse( buf )
+