diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2008-06-18 20:49:58 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2008-06-18 20:49:58 +0000 |
commit | 671edc4bdfe7652384d23d440268bb862414c4d2 (patch) | |
tree | 4e1cb7e1dd7b200ceb3662b94ab4080bb131f08c /Lib/xml | |
parent | bde7b5495aae4e98abf5c61c45505bf69cbfaf70 (diff) | |
download | cpython-671edc4bdfe7652384d23d440268bb862414c4d2.tar.gz |
Make a new urllib package .
It consists of code from urllib, urllib2, urlparse, and robotparser.
The old modules have all been removed. The new package has five
submodules: urllib.parse, urllib.request, urllib.response,
urllib.error, and urllib.robotparser. The urllib.request.urlopen()
function uses the url opener from urllib2.
Note that the unittests have not been renamed for the
beta, but they will be renamed in the future.
Joint work with Senthil Kumaran.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/xmlbuilder.py | 14 | ||||
-rw-r--r-- | Lib/xml/sax/saxutils.py | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Lib/xml/dom/xmlbuilder.py b/Lib/xml/dom/xmlbuilder.py index dc7c5d4705..d798624709 100644 --- a/Lib/xml/dom/xmlbuilder.py +++ b/Lib/xml/dom/xmlbuilder.py @@ -190,8 +190,8 @@ class DOMBuilder: options.errorHandler = self.errorHandler fp = input.byteStream if fp is None and options.systemId: - import urllib2 - fp = urllib2.urlopen(input.systemId) + import urllib.request + fp = urllib.request.urlopen(input.systemId) return self._parse_bytestream(fp, options) def parseWithContext(self, input, cnode, action): @@ -223,14 +223,14 @@ class DOMEntityResolver(object): source.encoding = self._guess_media_encoding(source) # determine the base URI is we can - import posixpath, urlparse - parts = urlparse.urlparse(systemId) + import posixpath, urllib.parse + parts = urllib.parse.urlparse(systemId) scheme, netloc, path, params, query, fragment = parts # XXX should we check the scheme here as well? if path and not path.endswith("/"): path = posixpath.dirname(path) + "/" parts = scheme, netloc, path, params, query, fragment - source.baseURI = urlparse.urlunparse(parts) + source.baseURI = urllib.parse.urlunparse(parts) return source @@ -242,8 +242,8 @@ class DOMEntityResolver(object): return self._opener def _create_opener(self): - import urllib2 - return urllib2.build_opener() + import urllib.request + return urllib.request.build_opener() def _guess_media_encoding(self, source): info = source.byteStream.info() diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index a569c1d0d3..e5d43a597a 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -3,7 +3,7 @@ A library of useful helper classes to the SAX classes, for the convenience of application and driver writers. """ -import os, urlparse, urllib +import os, urllib.parse, urllib.request from . import handler from . import xmlreader @@ -289,8 +289,8 @@ def prepare_input_source(source, base = ""): source.setSystemId(sysidfilename) f = open(sysidfilename, "rb") else: - source.setSystemId(urlparse.urljoin(base, sysid)) - f = urllib.urlopen(source.getSystemId()) + source.setSystemId(urllib.parse.urljoin(base, sysid)) + f = urllib.request.urlopen(source.getSystemId()) source.setByteStream(f) |