mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Reference cycle fixes
This commit is contained in:
parent
8fcaa92c5f
commit
73678dac48
4 changed files with 144 additions and 144 deletions
|
|
@ -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 )
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue