diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-27 15:04:59 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-27 15:04:59 +0200 |
commit | 60a8b4592bf38b642d204858002737c2bfe5c087 (patch) | |
tree | b0d0314b7c720962df18f7865d36ed9f86b48d5c /Lib/unittest/mock.py | |
parent | 88983fee9e51b919e0435b26f4df826ed7652bd0 (diff) | |
parent | 0e54a4b4dd2672ea0418aa2136c04a60adc3b36e (diff) | |
download | cpython-60a8b4592bf38b642d204858002737c2bfe5c087.tar.gz |
Issue #29058: All stable API extensions added after Python 3.2 are now
available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of
the minimum Python version supporting this API.
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index f134919888..367c1e19ce 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -104,26 +104,16 @@ def _check_signature(func, mock, skipfirst, instance=False): def _copy_func_details(func, funcopy): - funcopy.__name__ = func.__name__ - funcopy.__doc__ = func.__doc__ - try: - funcopy.__text_signature__ = func.__text_signature__ - except AttributeError: - pass # we explicitly don't copy func.__dict__ into this copy as it would # expose original attributes that should be mocked - try: - funcopy.__module__ = func.__module__ - except AttributeError: - pass - try: - funcopy.__defaults__ = func.__defaults__ - except AttributeError: - pass - try: - funcopy.__kwdefaults__ = func.__kwdefaults__ - except AttributeError: - pass + for attribute in ( + '__name__', '__doc__', '__text_signature__', + '__module__', '__defaults__', '__kwdefaults__', + ): + try: + setattr(funcopy, attribute, getattr(func, attribute)) + except AttributeError: + pass def _callable(obj): |