diff options
author | Paul Prescod <prescod@prescod.net> | 2000-07-01 04:58:47 (GMT) |
---|---|---|
committer | Paul Prescod <prescod@prescod.net> | 2000-07-01 04:58:47 (GMT) |
commit | 73678dac48e5858e40cba6d526970cba7e7c769c (patch) | |
tree | 9cb93c23e4a2cd4a881e86694f8204e33c2ed106 /Lib/xml/sax/__init__.py | |
parent | 8fcaa92c5f4290c0ea31f2680c87635bc751303f (diff) | |
download | cpython-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__.py | 24 |
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 ) + |