diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-16 14:25:32 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-16 14:25:32 -0500 |
commit | 88c77110867997d171cdee17e4b52e4011e00911 (patch) | |
tree | db08a1c016bc6afc179bcfe8db0dd385e5f2ebc5 | |
parent | 827c4c365fccad37907688b3518e7d351d3bfc5b (diff) | |
download | external_python_setuptools-88c77110867997d171cdee17e4b52e4011e00911.tar.gz external_python_setuptools-88c77110867997d171cdee17e4b52e4011e00911.tar.bz2 external_python_setuptools-88c77110867997d171cdee17e4b52e4011e00911.zip |
Replace global variable serving as an implicit cache with an explicit 'once' decorator.
-rw-r--r-- | setuptools/ssl_support.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/setuptools/ssl_support.py b/setuptools/ssl_support.py index 2313651f..0635c43d 100644 --- a/setuptools/ssl_support.py +++ b/setuptools/ssl_support.py @@ -2,6 +2,7 @@ import os import socket import atexit import re +import functools from setuptools.extern.six.moves import urllib, http_client, map, filter @@ -204,14 +205,18 @@ def opener_for(ca_bundle=None): ).open -_wincerts = None +# from jaraco.functools +def once(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + if not hasattr(func, 'always_returns'): + func.always_returns = func(*args, **kwargs) + return func.always_returns + return wrapper +@once def get_win_certfile(): - global _wincerts - if _wincerts is not None: - return _wincerts.name - try: from wincertstore import CertFile except ImportError: |