[Python-checkins] cpython: Make decorators used in packaging preserve docstrings

eric.araujo python-checkins at python.org
Fri Jun 17 21:10:33 CEST 2011


http://hg.python.org/cpython/rev/203407036e46
changeset: 70854:203407036e46
user: Éric Araujo <merwok at netwok.org>
date: Fri Jun 17 21:10:21 2011 +0200
summary:
 Make decorators used in packaging preserve docstrings
files:
 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
--- a/Lib/packaging/pypi/simple.py
+++ b/Lib/packaging/pypi/simple.py
@@ -15,8 +15,8 @@
 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 @@
 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 @@
 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)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /