summaryrefslogtreecommitdiff
path: root/Lib/xml/sax/saxutils.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-26 17:23:09 +0000
committerFred Drake <fdrake@acm.org>2000-09-26 17:23:09 +0000
commit0872e0585196a894c8c2c2dbea1a0fdd68391c90 (patch)
tree6c2a7553349464c5e0d17b23d5c1b6913e234119 /Lib/xml/sax/saxutils.py
parent1bac645d8f0d1264ac3b59ad6b4a34c543cf1885 (diff)
downloadcpython-git-0872e0585196a894c8c2c2dbea1a0fdd68391c90.tar.gz
Fix handling of file inputs on Windows; passing them to urllib.urlopen()
caused the drive letter to cause urlopen() to think it was an unrecognized URL scheme. This only passes system ids to urlopen() if the file does not exist. It works on Windows & Unix. It should work everywhere else as well.
Diffstat (limited to 'Lib/xml/sax/saxutils.py')
-rw-r--r--Lib/xml/sax/saxutils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index 3f130f3af5..a25b41f096 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -198,14 +198,16 @@ def prepare_input_source(source, base = ""):
source = xmlreader.InputSource(source)
source.setByteStream(f)
- if source.getByteStream() == None:
+ if source.getByteStream() is None:
sysid = source.getSystemId()
- if urlparse.urlparse(sysid)[0] == '':
+ if os.path.isfile(sysid):
basehead = os.path.split(os.path.normpath(base))[0]
source.setSystemId(os.path.join(basehead, sysid))
+ f = open(sysid, "rb")
else:
source.setSystemId(urlparse.urljoin(base, sysid))
+ f = urllib.urlopen(source.getSystemId())
- source.setByteStream(urllib.urlopen(source.getSystemId()))
+ source.setByteStream(f)
return source