diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2000-09-24 21:31:06 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2000-09-24 21:31:06 (GMT) |
commit | 58af43fd760c2d7d0d8238b7919cf8fa9f1b6dbe (patch) | |
tree | dc6f958ea915438ae6c4316c253d2a3e6f05b7ee /Lib/xml/sax/__init__.py | |
parent | eedb5764a51ce4f18c2505ecad9c55d18be22961 (diff) | |
download | cpython-58af43fd760c2d7d0d8238b7919cf8fa9f1b6dbe.zip cpython-58af43fd760c2d7d0d8238b7919cf8fa9f1b6dbe.tar.gz cpython-58af43fd760c2d7d0d8238b7919cf8fa9f1b6dbe.tar.bz2 |
[Patch 101634]
xml.sax: Fix parse and parseString not to rely on ExpatParser
Greatly simplify import logic by using __import__
saxutils: Support Unicode strings and files as parameters to
prepare_input_source
Diffstat (limited to 'Lib/xml/sax/__init__.py')
-rw-r--r-- | Lib/xml/sax/__init__.py | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py index 7c62ea1..1f1f58e 100644 --- a/Lib/xml/sax/__init__.py +++ b/Lib/xml/sax/__init__.py @@ -26,7 +26,7 @@ from _exceptions import SAXException, SAXNotRecognizedException, \ def parse(source, handler, errorHandler=ErrorHandler()): - parser = ExpatParser() + parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) parser.parse(source) @@ -39,7 +39,7 @@ def parseString(string, handler, errorHandler=ErrorHandler()): if errorHandler is None: errorHandler = ErrorHandler() - parser = ExpatParser() + parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) @@ -87,29 +87,8 @@ if sys.platform[ : 4] == "java": return drv_module.create_parser() else: - import imp as _imp - - def _rec_find_module(module): - "Improvement over imp.find_module which finds submodules." - path="" - for mod in string.split(module,"."): - if path == "": - info = (mod,) + _imp.find_module(mod) - else: - info = (mod,) + _imp.find_module(mod, [path]) - - lastmod = _imp.load_module(*info) - - try: - path = lastmod.__path__[0] - except AttributeError, e: - pass - - return info - def _create_parser(parser_name): - info = _rec_find_module(parser_name) - drv_module = _imp.load_module(*info) + drv_module = __import__(parser_name,{},{},['create_parser']) return drv_module.create_parser() del sys |