diff options
author | Éric Araujo <merwok@netwok.org> | 2011-06-17 19:10:21 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-06-17 19:10:21 (GMT) |
commit | 3c8ca089b1955a16e098cbb65ae3fb12e0cc53ad (patch) | |
tree | 10c72740d44208a287de1fec672634562e5f8485 | |
parent | 980d344ff3d99b8893619b00a4ef3752c8ff0a0e (diff) | |
download | cpython-3c8ca089b1955a16e098cbb65ae3fb12e0cc53ad.zip cpython-3c8ca089b1955a16e098cbb65ae3fb12e0cc53ad.tar.gz cpython-3c8ca089b1955a16e098cbb65ae3fb12e0cc53ad.tar.bz2 |
Make decorators used in packaging preserve docstrings
-rw-r--r-- | Lib/packaging/pypi/simple.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/packaging/pypi/simple.py b/Lib/packaging/pypi/simple.py index 1dcb8ce..74cbf8d 100644 --- a/Lib/packaging/pypi/simple.py +++ b/Lib/packaging/pypi/simple.py @@ -15,8 +15,8 @@ import urllib.parse import urllib.error import os - from fnmatch import translate +from functools import wraps from packaging import logger from packaging.metadata import Metadata from packaging.version import get_version_predicate @@ -53,8 +53,9 @@ REL = re.compile("""<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>""", re.I) def socket_timeout(timeout=SOCKET_TIMEOUT): """Decorator to add a socket timeout when requesting pages on PyPI. """ - def _socket_timeout(func): - def _socket_timeout(self, *args, **kwargs): + def wrapper(func): + @wraps(func) + def wrapped(self, *args, **kwargs): old_timeout = socket.getdefaulttimeout() if hasattr(self, "_timeout"): timeout = self._timeout @@ -63,13 +64,14 @@ def socket_timeout(timeout=SOCKET_TIMEOUT): return func(self, *args, **kwargs) finally: socket.setdefaulttimeout(old_timeout) - return _socket_timeout - return _socket_timeout + return wrapped + return wrapper def with_mirror_support(): """Decorator that makes the mirroring support easier""" def wrapper(func): + @wraps(func) def wrapped(self, *args, **kwargs): try: return func(self, *args, **kwargs) |