[Python-checkins] CVS: python/dist/src/Lib/xml/sax saxutils.py,1.7,1.8

Fred L. Drake python-dev@python.org
Tue, 26 Sep 2000 10:23:25 -0700


Update of /cvsroot/python/python/dist/src/Lib/xml/sax
In directory slayer.i.sourceforge.net:/tmp/cvs-serv26794/Lib/xml/sax

Modified Files:
	saxutils.py 
Log Message:

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.


Index: saxutils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** saxutils.py	2000/09/24 21:31:06	1.7
--- saxutils.py	2000/09/26 17:23:09	1.8
***************
*** 199,211 ****
          source.setByteStream(f)
  
!     if source.getByteStream() == None:
          sysid = source.getSystemId()
!         if urlparse.urlparse(sysid)[0] == '':
              basehead = os.path.split(os.path.normpath(base))[0]
              source.setSystemId(os.path.join(basehead, sysid))
          else:
              source.setSystemId(urlparse.urljoin(base, sysid))
              
!         source.setByteStream(urllib.urlopen(source.getSystemId()))
          
      return source
--- 199,213 ----
          source.setByteStream(f)
  
!     if source.getByteStream() is None:
          sysid = source.getSystemId()
!         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(f)
          
      return source