1. Armin Rigo
  2. cpython-withatomic


Fred Drake  committed 5d08909

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.

  • Participants
  • Parent commits 3a59a07
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/xml/sax/saxutils.py

View file
  • Ignore whitespace
         source = xmlreader.InputSource(source)
-    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")
             source.setSystemId(urlparse.urljoin(base, sysid))
+            f = urllib.urlopen(source.getSystemId())
-        source.setByteStream(urllib.urlopen(source.getSystemId()))
+        source.setByteStream(f)
     return source