summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-11 20:13:10 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-11 20:13:10 (GMT)
commit185147f1d06dd56be7f28c4af29ae152df7f4ff5 (patch)
tree0f3cdfecfdca2884ea2661189e93746391b1893b /Lib
parent7ffbd2f86c7ab034415d48a734582803684da18c (diff)
downloadcpython-185147f1d06dd56be7f28c4af29ae152df7f4ff5.zip
cpython-185147f1d06dd56be7f28c4af29ae152df7f4ff5.tar.gz
cpython-185147f1d06dd56be7f28c4af29ae152df7f4ff5.tar.bz2
Test urlparse cache with try/except instead of has_key.
This makes it thread-safe again.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urlparse.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 31d853a..aeed393 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -44,8 +44,10 @@ def clear_cache():
# (e.g. netloc is a single string) and we don't expand % escapes.
def urlparse(url, scheme = '', allow_framents = 1):
key = url, scheme, allow_framents
- if _parse_cache.has_key(key):
+ try:
return _parse_cache[key]
+ except KeyError:
+ pass
if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
clear_cache()
netloc = path = params = query = fragment = ''