diff options
author | Thomas Kemmer <tkemmer@computer.org> | 2021-01-24 20:35:07 +0100 |
---|---|---|
committer | Thomas Kemmer <tkemmer@computer.org> | 2021-01-24 20:35:58 +0100 |
commit | 2a2e715c31aeb7ba45580937406ea9d4164067d1 (patch) | |
tree | a925486fb36a4d13f43d5a876af637d18e7221da | |
parent | 4862ce336ca177dd79bafea67a05302c22102532 (diff) | |
download | cachetools-2a2e715c31aeb7ba45580937406ea9d4164067d1.tar.gz |
Fix #200: Clean up __missing__ example.
-rw-r--r-- | docs/index.rst | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/docs/index.rst b/docs/index.rst index 945bd78..1c4d05b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -171,13 +171,10 @@ key is not found: ... def __missing__(self, key): ... """Retrieve text of a Python Enhancement Proposal""" ... url = 'http://www.python.org/dev/peps/pep-%04d/' % key - ... try: - ... with urllib.request.urlopen(url) as s: - ... pep = s.read() - ... self[key] = pep # store text in cache - ... return pep - ... except urllib.error.HTTPError: - ... return 'Not Found' # do not store in cache + ... with urllib.request.urlopen(url) as s: + ... pep = s.read() + ... self[key] = pep # store text in cache + ... return pep >>> peps = PepStore(maxsize=4) >>> for n in 8, 9, 290, 308, 320, 8, 218, 320, 279, 289, 320: |