diff options
author | Guido van Rossum <guido@python.org> | 2000-08-24 16:18:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-08-24 16:18:04 (GMT) |
commit | ba3113807dc63e827463d641c1b4511b064d3c88 (patch) | |
tree | 839d9119fccf66273b4b1ef53452da779e647568 /Lib/urllib.py | |
parent | ff5364ac9d8583d65dd331165736f9cf2339880d (diff) | |
download | cpython-ba3113807dc63e827463d641c1b4511b064d3c88.zip cpython-ba3113807dc63e827463d641c1b4511b064d3c88.tar.gz cpython-ba3113807dc63e827463d641c1b4511b064d3c88.tar.bz2 |
Promote the server version from a local variable to a class variable,
so that a subclass can override it.
This partly addresses Bug #112634 -- but the documentation is still
wrong, since it suggests that you can set self.version *after* calling
the base class __init__. In fact it must be done *before*.
I'll fix that too.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index cdea631..7275a5a 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -28,7 +28,7 @@ import os import sys -__version__ = '1.12' # XXX This version is not always updated :-( +__version__ = '1.13' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size @@ -82,6 +82,8 @@ class URLopener: __tempfiles = None + version = "Python-urllib/%s" % __version__ + # Constructor def __init__(self, proxies=None, **x509): if proxies is None: @@ -90,8 +92,7 @@ class URLopener: self.proxies = proxies self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file') - server_version = "Python-urllib/%s" % __version__ - self.addheaders = [('User-agent', server_version)] + self.addheaders = [('User-agent', self.version)] self.__tempfiles = [] self.__unlink = os.unlink # See cleanup() self.tempcache = None |